Monday, August 25, 2008

About killing

Few days ago I accidentally hit a sparrow with my car. The poor creature did not survive. There's a really heavy feeling that grabs you right after that moment. Anger, frustration, trying to exonerate one's self. Sadness.

And if that's not enough, yesterday I hit a fox on the highway. I did not even stop to see what happened for which I kinda feel guilty. Again the sadness and thinking about life, the universe and everything else.

Damn bad luck. I have never hit anything before. And from the feeling of it - I'm no good for taking lives - I just can't bare the thought of it.

 Wednesday, August 20, 2008

Blogs that supply part of the content in the RSS/Atom feeds

There are blogs that only supply a resume or part of the content in the RSS. And the reason, I guess, is that they want you to leave the comfort of your own RSS reader and visit their site and maybe see some ads or who-cares-else what.

Well, FUCK THEM. The best I know are not doing it. Actually the best I know have no ads and have minimalistic web sites (I understand it as only content and unobtrusive navigation buttons/links).... and..... provide outstanding content.

Blogs that do that:
http://www.karieri.bg/blog/
http://www.nova-rabota.com/

I decided to stop reading them.


Other things that turn me down - copyright footer, a lot of links like "vote for me in ...." and guys that start taking themselves too seriously. For the latter I'm ready to make an exception, because some of them have an amazing style.

I should name my blog "Complaining about stuff"

The "sucks" category is flourishing.

But it's damn easier to complain about stuff, than to write something meaningful.

I have to change that.

My blog in Internet Explorer

I just noticed it. It sucks. It's ugly, the font is ugly. How did I not notice that.
OOO, man, I have to fix it :(

In firefox it looks fine. Damn.

Vital equipment dying

I think I'm having a bad dream.
Most of the most important technical equipment around me is failing:

First the phone: SonyEricsson K750i. An amazing machine. Very sturdy, survived a swimming pool, being lost in the snow while snowboarding, numerous hits, is now dead.

The laptop's battery completely fucked up, it's constantly overheating. The laptop itself is scaring me up - not to die one day - it's a DELL, so....

My car is on the end of its usable life. Although I'm so thankful to it for saving my life after all the stupid things I did when I was younger, I have to change it.

I'm planning to buy a motorcycle.

It's partly my fault - most of the equipment was showing dreadful signs for a long time, but I constantly postpone to take measures.

So now to be able to buy all that I'm thinking of finding a second job or sell a kidney.

 Friday, August 15, 2008

I hate CDs/DVDs

I really do. Windows doesn't seem to understand them - the whole system stops and waits for a single DVD. The laptop is shaking.

Read/write times are really slow. Burning them with the windows's ATAPI service is hell.

When used to working with 3-5 MB/sec without worm-up times and spin times and whatever else times, it's really annoying.

But DVDs are the only reasonable way to give someone 15 GB even though you'll have to spend 2 hours to burn them.

P.S. I want to remove my laptop's DVD combo whatever bullshit, but I can't :( It's such a waste of weight and space.

Vista doesn't want to update to SP1

I don't know why. The update just does not want to come.
There are always other updates.

I'm too afraid to update to SP1 manually. Who knows what will happen.

And I want to stress that this is a legal copy.

Firefox is slow and youtube fails

Firefox is getting really slow. I don't know why, it may be due to too many plug-ins - I have 4 or 5.

And if working for sometime it stops playing flash streaming videos (youtube, google video....).

It has to be restarted. I'm disappointed.

Vista/XP can't burn a single CD/DVD without infuriating you

This is part of the series 'Vista sucks'. Although XP sucks as much as Vista in this case.

There was a feature first introduced in XP for burning CDs. In Xp the service was called something like ATAPI burning or whatever. Couldn't burn DVDs. In Vista the same software could burn DVDs. I couldn't find the service name. I may have missed it somehow.

So this software was a nice feature - simple, fairly stable.

But it's so darn slow and requires twice as much space as the burned data. Here's why:

First you copy the files on the CD/DVD with Windows Explorer. This copies the files in a cache of some kind. Trying to burn 4.5 GB requires 4-5 minutes of copying - and the machine is unusable  - copying utilizes the HDD. If you do something else it could take up to 20 min.

Then to burn them, the wizard should be started - this again copies the files to another cache I guess. Again 5 to 20 minutes.

This means 9 GB of space needed + the actual 4.5 GB. And a lot of time.

Vista/XP you messed up a good idea again. Vista/XP you suck.

As far as I can remember Nero was a lot faster, no cache needed, or at least no that much. Is Nero still good? Is there a light version of it?

 Monday, July 21, 2008

Adding columns to join tables (in the context of JPA/Hibernate)

At some point in a @ManyToMany relationship I had to add some extra columns in the join table (the middle table).

Here's what Gavin King says in Java Persistence with Hibernate (a notable book on the subject):

Adding columns to join tables
You can use two common strategies to map such a structure to Java classes. The first strategy requires an intermediate entity class for the join table and is mapped with one-to-many associations. The second strategy utilizes a collection of components, with a value-type class for the join table.

Later in that chapter for the first approach (the extra entity for the middle table):
The primary advantage of this strategy is the possibility for bidirectional navigation: You can get all items in a category {...} and the also navigate from the opposite direction {...}. A disadvantage is the more complex code needed to manage {...} entity instances to create and remove associations—they have to be saved and deleted independently, and you need some infrastructure, such as the composite identifier. However, you can enable transitive persistence with cascading options on the
collections {...}, as explained {...}, “Transitive persistence.”

Later in that chapter for the second approach (the collection of components approach):
That’s it: You’ve mapped a ternary association with annotations. What looked
incredibly complex at the beginning has been reduced to a few lines of annota-
tion metadata, most of it optional.

Naively enough I chose the second approach. Who cares that there's a hibernate dependency in my JPA data access layer. I already have a few (a hibernate interceptor).

In this approach I had to use the @CollectionOfElements annotation. @CollectionOfElements works like that: it maps a collection (set, map, list) of something to a table. This table has no entity attached to it. It can work with value types, Strings and @Embeddables. In my case it had to be the @Embeddable.

Let me give you an example - it will clear things up: there are classes and there are students - two entities. There can be two classes with many students some of which are the same - so the relationship is @ManyToMany. The extra column in the join table would the grade of the student in that class.

So the approach with the @CollectionOfElements works like that: one of the entities holds the relationship - let it be the class entity - so it has something like that:

@Entity
public class Class {
    @Version
    private int version;
    ...
    @org.hibernate.annotations.CollectionOfElements
    private Set<GradedStudent> students;
    ...
}


Student is a simple entity, no code needed. Let's call the student with the grade an GradedStudent:
@Embeddable
public class GradedStudent {
    ...
    @OneToOne(..., cascade = {MERGE, PERSIST, REFRESH})
    private Student student;
    ...
    @Column( nullable = false, ... )
    private int grade;
    ...
}

That's pretty much it. Seems simple, you would think and straightforward.

BUT IT DOESN'T WORK.

Here's what gets wrong:
  1. Everytime a class entity gets queried, it's version gets incremented. This makes updating a disconnected entity far more difficult and makes the @Version kind of obsolete.
    Solution: none, I couldn't find anything remotely connected to this problem on the net.
  2. The primary key in the join table (with a name like 'class_gradedstudent') is not the [class_id, student_id] but is [class_id, student_id, grade]. If you put extra columns in the join table and they are nullable = false, they would become part of the primary key.
  3. Cascading fails. You have to create and persist a Student first in order it to become a part of a certain class entity. Even though a GradedStudent is said to cascade a Student.
    Solution: none, I tried everything I could think of - no luck. I couldn't find anything remotely connected to this problem on the net.

Regarding 2: a quotation from the same book:
There is only
one change to the database tables: The {...} table now has a primary
key that is a composite of all columns, not only the ids of the two object, as in
the previous section. Hence, all properties should never be nullable—otherwise
you can’t identify a row in the join table.
Well, what if I don't want that? It doesn't say.

So, actually the second approach is not an option.
 Friday, July 18, 2008

Gotcha MTEL, YOU CHEATING BASTARDS

From some time I noticed that Mtel (my mobile service operation) is using VoIP when I'm calling an Mtel number while roaming.
When I'm calling another operator's number while still roaming, there's no VoIP.

CHEAP BASTARDS. For these prices you can at least provide a decent service - a VoIP call is with bad quality and the callee cannot see who's calling, he sees some service number.

BUT THATS NOT ALL.

The top of the cherry is that when Mtel is using VoIP they clearly cannot see whether the other side answers or not, so no matter whether you make a successful call or not - while you're ringing you get billed. That's not right, is it?!

I found out all that today while checking my bill. Two months ago while in Brno I made a call and was quite sure that I would get billed for that call even though nobody answered.

GOTCHA, YOU CHEAP BASTARDOs


Update: other case of proved cheating:
Mtel made me pay 200 bucks for half a megabyte of internet while roaming. Before that I explicitly asked for the price. It came out that the price is 10 times more and they charge every GPRS session for a full megabyte (with 10 times the prices) without saying it.

Few months ago I caught them billing me for an international call to a friend I haven't spoken with for at least a couple of years.

 Monday, July 14, 2008

MySQL, I hate you so much [Installing mysql as a service]

The first idea was to have the DB (MySQL) start as part of the script that launched the tests. Google couldn't find anything good. MySQL is one of the most unintuitive things I have ever seen, so the decision was to not try to figure it out on my own.

The next thing was to install MySQL as a service. That turned out to be difficult.

I tried to install MySQL as a service:

/>mysqld --install

As easy as that. The problem is IT DID NOT WORK. The service did not want to start.

After some reading it came out that the RIGHT way was to do it like that:

__correct dir__/><<path>>\mysqld.exe --install MySQL --defaults-file="<<path>>\my.ini"

Why do I have to supply the mysql directory explicitly?
Why do I have to supply the my.ini directory explicitly?

Why doesn't mysqld give me an error message when I install it without the needed parameters?
Why doesn't mysqld give me an error message when I install it without the needed explicit paths?

...is beyond my inderstanding.

MySQL, you are a disgrace.
MySQL, not only are you not a real RDBMS but you can't even start without making your users' life misserable.


Google mail servers fail?! All of them?

Connection timed out on all their servers?!

Technical details of temporary failure:
TEMP_FAILURE: The recipient server did not accept our requests to connect.
[ASPMX.L.GOOGLE.com. (1): Connection timed out]
[ALT1.ASPMX.L.GOOGLE.com. (5): Connection timed out]
[ALT2.ASPMX.L.GOOGLE.com. (5): Connection timed out]
[ASPMX3.GOOGLEMAIL.com. (10): Connection timed out]
[ASPMX5.GOOGLEMAIL.com. (10): Connection timed out]
[ASPMX2.GOOGLEMAIL.com. (10): Connection timed out]
[ASPMX4.GOOGLEMAIL.com. (10): Connection timed out]

 Friday, July 11, 2008

The sources for hibernate-entitymanager.jar, version 3.2.1GA

Yea, it was difficult. So difficult that I had to extract the sources from a zipped project file, put them into archive and rename to jar file. And hope that the versions I'm using are mathing....

The JBoss jar says it's implemented by JBoss.
JBoss/hibernate-entitymanager.jar/META-INF/MANIFEST.MF:
Manifest-Version: 1.0
Product: Hibernate EntityManager
Specification-Title: JBoss
Created-By: 1.5.0_09-b03 (Sun Microsystems Inc.)
Specification-Version: 4.2.2.GA
Implementation-Vendor-Id: http://www.jboss.org/   WTF?
Version: 3.2.1.GA
Implementation-URL: http://www.jboss.org/
Ant-Version: Apache Ant 1.6.5
Implementation-Title: JBoss [Trinity]
Specification-Vendor: JBoss (http://www.jboss.org/)
Implementation-Version: 4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=20
 0710221139)
Implementation-Vendor: JBoss Inc.

However, the JBoss source does not have the sources.
http://repository.jboss.org/hibernate-entitymanager/3.2.1.GA/
WTF number 2?


In the hibernate downloads the source is missing as a separate download
http://sourceforge.net/project/showfiles.php?group_id=40712&package_id=156160
WTF number 3?

Finally, found it in the zip file in the last link. I was desparate, thinking of using the repositories here:
http://anonsvn.jboss.org/repos/hibernate/entitymanager/tags/
Had to extract it, re-zip it and hope the versions match. So far so good.

Why does it have to be so difficult?!

 Thursday, July 10, 2008

Overriding a method with a raw type, want to use generics in the override

I want to override that api.org.hibernate.Interceptor#postFlush(java.util.Iterator)
I want to do it like that:
@Override
public void postFlush( Iterator<?> entities ) throws CallbackException {...}
Does not work - the method is not with the same signature ?!

Then:
@Override
public void postFlush( Iterator<Object> entities ) throws CallbackException {...}
Does not work - the method is not with the same signature ?! WTF?

The only thing that does work (without a silly warning) is that:
@Override
public void postFlush( @SuppressWarnings( "unchecked" ) Iterator entities ) throws CallbackException {


Why?!!
 Tuesday, July 08, 2008

JUnit, exceptions in @Before and @After methods

JUnit spec (not very easy to find) states, that if there's an exception in the @Before method, the test is not called. True. BUT

JUnit spec does not state that in this case the @After method is called.

JUnit spec also does not state that if there's an exception in both the @Before and @After methods, the second exception (guess which one) overrides the first one. In my case the first one causes the second one (the first one is ConnectionClosed or similar, the second one is a NullPointerException because the resource is not initialized).

So the real reason for the problem is lost. One will say - avoid exceptions in the @After method - that's what I just did (and the real exception was printed), but finding the reason for that was not easy and straightforward.

I'm using junit 4.4, the default runner is JUnit4ClassRunner, JUnit4ClassRunner is calling ClassRoadie.runProtected():

public void runProtected() {
    try {
        runBefores();
        runUnprotected();
    } catch (FailedBefore e) {
    } finally {
        runAfters();
    }
}

This is the reason for the mentioned override. I hate when finally does that.
 Friday, June 20, 2008

'Sucks' category

There's a trend - there are a lot of articles here in which I bitch about something. So there should be a category called 'Sucks'.

Update: reviewing the articles I found a lot of candidates for the category, it comes out that all I'm doing is bitching about stuff - I should change the subtitle of the blog :)

@Override in eclipse

When one implements an interface, the template in Eclipse puts an @Override and it does not complain about it. Ant javac task also compiles without warnings.

Sometimes other Eclipse instances start to complain exactly for that @Override stating that there's no method that's overridden. Well, Eclipse, please do make up your mind.

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Override.html
"Indicates that a method declaration is intended to override a method declaration in a superclass. If a method is annotated with this annotation type but does not override a superclass method, compilers are required to generate an error message."

Well, that's not very clear. As far as I remember an Interface is a pure abstract class, right? So, which one's correct.

P.S. Sometime ago I was having a similar problem with Eclipse and generics - Eclipse only gave a warning about something (can't remember what exactly), but the javac said that it was an error - Google said something like "eclipse uses jikes, you use javac". So what, aren't there specs?!


Update: apparently JDK5 (or 1.5, suit yourself) does not allow that. So in order to get all the wrong @Overrides - set the Compliance level to 5.0 (Eclipse -> Window -> Preferences -> Java -> Compiler -> Compiler compliance level ) - and..... correct them. I have 29 left.

Referrers from live.com

All the referrers to this blog from live.com come like that:
http://search.live.com/results.aspx?q=class&form=QBHP or
http://search.live.com/results.aspx?q=interface&form=QBHP

The search word seems to be only 'class'. I can't believe that I come out in a search for only the word 'class'. I guess all the other words from the search are stripped which, if on purpose, is stupid, and, if not, ignorant.

 Wednesday, June 11, 2008

Vista connected to the internet - does not know about it

Check it out:



Happened after installing updates but not restarting afterwards.
 Tuesday, June 10, 2008

ant junitreport task cannot set vm arguments

ant junitreport task creates a html report from junit xml report files.
If the xml files are numerous enough and/or large enough (mine were 102MB total ), the task crashes with OutOfMemoryError.

Solution? set the GLOBAL variable ANT_OPTS. This changes defautl ant conf for the whole machine this setting is on.

Not very nice :)

CVS: dying gasps from server

Why can't there be software that just works?!

There's a CVS server (version 1.11.22) [one can get the version with cvs version -d cvs_root] on a Linux machine.

There's a Hudson on the Linux machine that queries the cvs just fine.

I have Hudson on a Windows machine that gives me:
cvs checkout: dying gasps from server unexpected

The explanation? Here's the best I could find:
dying gasps from server unexpected
There is a known bug in the server for CVS 1.9.18 and older which can cause this. For me, this was reproducible if I used the -t global option. It was fixed by Andy Piper's 14 Nov 1997 change to src/filesubr.c, if anyone is curious. If you see the message, you probably can just retry the operation which failed.

Sources:
http://magic.astro.uni-wuerzburg.de:81/mars/cvserror.html
http://cvsman.com/cvs-1.12.12/cvs_210.php
http://developer.apple.com/opensource/cvs/cederquist/cvs_174.html

Now check the version of the server I have (in the beginning). So what do we do now?!

Why can't there be software that just works?!
 Friday, June 06, 2008

Eclipse, interface implemented by classes, but the implementation is in a base class

Suppose there's an interface

interface PrimaryObject {
    int getVersion();
}


and

public class Base /* not inheriting PrimaryObject */ {
    int getVersion(){}
}


now suppose there are a lot of classes like

public class Class1 extends Base implements PrimaryObject {
}

So why did I mention Eclipse in the title:
When you go to the interface and press Ctrl + T on the interface itself you get a list of all the classes like Class1:



But you you press Ctrl + T on the method you get NOTHING:



Eclipse fails to show all the classes that implement this interface and this method.
 Thursday, June 05, 2008

SG Expressbank

Another bank that I'm unhappy with - SG Expressbank. Reasons
  1. They charge me with 0.69 on ATM withdrawal.
  2. They charge me with 1.39 (monthly fee)
  3. Interest rate: 0.00
  4. E banking application - outrageously bad (screws up every file format I request, cannot send money to an account without going to the bank (some security shit), ugly, not intuitive)
  5. The service is far from good.

I'm looking for a decent bank. Any ideas?

 Wednesday, April 30, 2008

EJB Sucks: one more reason why

I'm trying to like the specification, but I just can't.
Here's one more reason why:

I have SSB (Stateless Session Beans). The persistence is via JPA (implementation is Hibernate).

All my business method look something like:
...
public Object1 doSomething( Object2 ) throws ApplicationException1;
...


I use CMT (Container Managed Transactions) which means that the container calls begin() before the method call and commit() after the method call is over.

The problem: what happens if the transaction is rolled back?

A RollbackException is thrown. It looks common sense to try to rewrite it as ApplicationException1. Well.... YOU CAN'T.

No F way (at least not an easy one).

Solution1:
Make the Beans stateful and use SessionSynchronization. UGLY - I don't want to be stateful.

Solution2:
Implement TransactionSynchronizationRegistry - just look at it.

Solution3:
Make a facade EJB that calls my own EJBs which should use requiresNew. One more level of abstraction? I have to change the contract? I don't have just one Bean, so a wrapper for every single one of them?

Solution4:
Switch back to BMT (Bean Managed Transactions) and call begin() and commit() myself. Well then the container becomes useless. But my business methods are rarely longer than a few lines, so I'm choosing this one.


CMT without any simple way to plug after commit() and this is an enterprise level spec? Really?

I'd be really happy if someone corrects me and shows me a simple way to do what I need.

 Tuesday, April 29, 2008

MySQL sucks: one more reason

MySQL is a RDBMS. Or at least that's what it's creators claim it to be.

There's no other self respecting database who's only engine that implements transactions (innoDB) is not created by MySQL guys. Only until recently their own engine claims to support them. Even small in-process databases like Hypersonic and Derby fully support transactions from version one. Flawlessly.

Today I found one more reason for which I think MySQL should not be put under the category RDBMS:

Caused by: java.sql.SQLException: Too many tables; MySQL can only use 61 tables in a join
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2975)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1600)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1695)
        at com.mysql.jdbc.Connection.execSQL(Connection.java:3026)
        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1137)
        at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1231)
        at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:236)
        at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
        at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
        at org.hibernate.loader.Loader.doQuery(Loader.java:674)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
        at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)


Until recently the maximum was only 31 table. A major WTF?!

I would gladly bet that Hypersonic and Derby do not have a constraint like that (haven't investigated it though).

The stack trace is intently complete to show that this comes from Hibernate. This can be reproduced by having a rich object model with EAGER fetching.

Maybe I'll write a little more on the EAGER fetching and the issues I have: here.

 Monday, April 14, 2008

ICQ in GoogleTalk web client (gmail) - revised

What I wrote so far:

Open browser, go to the messenger part, log in, as simple as that.

First impressions:
  • no ICQ groups - that sucks - I used to use it a lot
  • aliases of people are retained ('MG Zas' for example) - which is a backup for groups ('group MG -> user Zas' becomes 'MG Zas').
  • Cyrillic characters work fine (if it was working with my other client - Pidgin/Gaim)

Concerning the standalone client - Google Talk - I have no idea if it works there - Google have a pretty wierd update policy - they update silently and only some clients - it sucks.



After all  - it's usable

After a week of using it this is what I noticed:
  1. Cyrillic doesn't always work with everybody, sometimes UTF-8 comes as cp-1251, even though the browser is in UTF-8.
    1. However, when I write, everybody sees it correctly.
  2. No way to give authorization to people, no way to ask for one.
  3. No way to see user info. No way, really.
  4. Some of my peers receive everything in html. It's hard to chat with them.
    1. I guess people without the official client.
After all - it's still usable, but I'm not going to recommend it to any more.

 Thursday, April 03, 2008

JVM Crash - have never seen that before



This is to JVM* what BSOD** is for Windows.

* Java Virtual Machine (the Java runtime)
**Blue Screen of Death (the thing windows does when it crashes)

Note: this happened when trying to merge (in Hibernate) an enum with a default private .ctor.

It is a happy day :)
 Monday, March 17, 2008

I failed exam 11

I have a bad feeling in my mouth. Too bad, it would have been a good T-shirt sign: 12 exams in 1 month. Now it's gonna be even longer 10/11 exams passed, 1/2 failed in one month :)

 Saturday, March 01, 2008

Spell checking software for MS Office 2007 (for Bulgarian language)

Look at this:



The message boxes are from a software that's supposed to be a spell-checker for Bulgarian.

Can this software fail at displaying Bulgarian characters?

The software is called Cyrilla Correct 2007 - it is intended for MS Office 2007 and this is a clean install of the trial version. This happens on first use.

A crap, I'm disappointed. And this is supposed to be the best thing on the market.

Does anybody know anything better? (Something that would work as seamlessly as Firefox's spell checker)
 Monday, February 25, 2008

Holy crap, I have a virus

I was warned by my good friend Google: