# Wednesday, June 11, 2008

Dream working place



What's missing is a hot girl bringing me stuff. The chair is awesome.

Vista connected to the internet - does not know about it

Check it out:



Happened after installing updates but not restarting afterwards.

E-banking - finally, there may be a winner

Seeing these posts first may help get the context of the talk:
What not to do when you're a bank
What to do when most e-banking interfaces suck?
First Investment Bank, the sequel
SG Expressbank

Being stuck with SG Expressbank made electronic transfers impossible, because they didn't work with epay.bg (prohibited) nor did they work with the e-banking software (every recepient has to be registered offline on-site (bank office), and for the ones that are registered the software does not work :) ).

Almost by accident I tested a card I had in epay.bg for the balance (most banks have stopped this service, because of too many requests). And... I got it. It was working. Strange.

I remebered that I had registered the e-banking for that bank and had left the user/pass somewhere.

After a few days of searching I found it.  Keep in mind that getting the user/pass from the bank was quite an adventure and took more than 20 days and quite a few trips to the local office.

The login screen is right on the main page of the bank. I was amazed to see how easy the generation of the certificate was. While doing it I saw that they support smart cars (e-signatures). Well done.

The interface is really user friendly. Supports almost everything or at least it seems so. I haven't tried it yet, because the bankaccount is nearly emtpy.

From the interface notifications can be defined: SMS notifications, email notifications. Now I'm waiting to see whether it works.

A minor drawback was that I can't tranfer money to another bank account via epay.bg - I guess only FIB cards can (FIB is connected to epay).

And because I'm lazy to do it the old-fashion way - now I'm using the only possible way to transfer money electronically from SG Expressbank card to the new card I have - the epay's microbill (микросметка) - another thing I have to learn how to use. It was quite straight forward to start up and use, but it takes a few days (in my case 2 full days) to tranfer the money and the commissions are not going to be small.

# 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.

@Lob in JPA, what if the class is not Serializable

If you have

@Entity
public class Student {
    @Lob
    private static MyPictureClass picture;



and suppose you forgot to put Serializable to MyPictureClass, then guess what: there's no exception. You have to check the data in the DB.

Surprise no2:
Suppose MyPictureClassis a base abstract class and it is not Serializable. Suppose every inheriting class is Serializable. Then what happens? Well one thing's for sure: there wouldn't be an exception, but there wouldn't be any data in the DB (you'll get null). The runtime checks (in Hibernate) check the signature of the defining class I suppose, not the supplied class at runtime - and I would assume the opposite, because serialization works the opposite way. Maybe it's because Hibernate does some runtime bytecode modifications.


Primitive types as fields in an JPA Entity

The JPA spec supports primitive types as @Columns. What they don't say (assuming Hibernate is the implementation (maybe TopLink does that too)) is that this column becomes nullable = false and the default value is the default for the primitive type. And that is so, even though the @Column(nullable by default is true.


So

@Entity
public class Person {
    private int age;
    private boolean male;

actually means

@Entity
public class Person {
    @Column( nullable = false )
    private int age = 0;
    @Column( nullable = false )
    private boolean male = false;

So watch out.

The new firefox 3.0 RC1 (update: RC2)

The new firefox 3.0 (not final yet - rc1 for now) is awesome. Most plug-ins don't work yet, but that changes very rapidly.
The engine itself is unbelievably fast and looks pretty stable - for a few days it crashed only once - trying to start the updater.

Try it, definitely try it. Link.

Update: the RC2 is out. The link points to it.

# 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?

hudson ant javac unit-tests fork=true, cannot start javac.exe compiler

Hudson is a continuous integration tool similar to CruiseControl. It has a very good web GUI for defining tasks unlike CruiseControl.
Inside it I have configured a call to an ant task.

Strangely enough in on of the projects that had to be build I got:

build.xml:200: Error running _path_to_jdk_/javac.exe compiler

Strange.

I double checked the script in eclipse. It worked.
Manual call to ant on the eclipse machine also worked.

Then I went to the Hudson machine (a test environment). I ran the script manually. The same freaking error.
I copied the whole dir to another place on the test environment: no problem.

Maybe it's the credentials: added read/write to all. Still the same error.

Then I ran the script with: ant -verbose and see what I got:


_path_\build.xml:75: _path_\javac.exe compiler
        at org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter.executeExternalCompile(DefaultCompilerAdapter.java:509)
        at org.apache.tools.ant.taskdefs.compilers.JavacExternal.execute(JavacExternal.java:61)
        at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:997)
        at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:820)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.Target.performTasks(Target.java:385)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
        at org.apache.tools.ant.Main.runBuild(Main.java:698)
        at org.apache.tools.ant.Main.startAnt(Main.java:199)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: java.io.IOException: Cannot run program "_path_\javac.exe": CreateProcess error=87, The parameter is incorrect
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
        at java.lang.Runtime.exec(Runtime.java:593)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Execute.java:828)
        at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:445)
        at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:459)
        at org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter.executeExternalCompile(DefaultCompilerAdapter.java:506)
        ... 20 more
Caused by: java.io.IOException: CreateProcess error=87, The parameter is incorrect
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
        at java.lang.ProcessImpl.start(ProcessImpl.java:30)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
        ... 29 more
--- Nested Exception ---
java.io.IOException: Cannot run program "_path_\javac.exe": CreateProcess error=87, The parameter is incorrect
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
        at java.lang.Runtime.exec(Runtime.java:593)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Execute.java:828)
        at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:445)
        at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:459)
        at org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter.executeExternalCompile(DefaultCompilerAdapter.java:506)
        at org.apache.tools.ant.taskdefs.compilers.JavacExternal.execute(JavacExternal.java:61)
        at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:997)
        at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:820)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.Target.performTasks(Target.java:385)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
        at org.apache.tools.ant.Main.runBuild(Main.java:698)
        at org.apache.tools.ant.Main.startAnt(Main.java:199)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: java.io.IOException: CreateProcess error=87, The parameter is incorrect
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
        at java.lang.ProcessImpl.start(ProcessImpl.java:30)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
        ... 29 more


Cannot create a process?!
That's weird.

So tired enough I did something desperate:

From
<javac fork="true"


I went to
<javac fork="false"

and it worked ..... :(

Keep in mind that in the same build project I was calling a few other build.xml doing <javac fork="true" several times before this one.
But this one was the only one having a reference to junit.jar (somewhere on the net I saw an article saying something about junit but don't remember what).

So I left it like this.

# Friday, May 23, 2008

And if that doesn't put a smile on your face...

... I don't know what will:




And because nowadays it's modern not to steal intelectual property, here's the source of the picture.

# Tuesday, May 20, 2008

First Investment Bank, the sequel

I was unhappy with my bank (What not to do when you're a bank).

Recently, the rumors about it going bankrupt became stronger and stronger so I cashed out my accounts and went for another bank.
The rumors came out to be fake and I felt like a dumb ass, becase I followed unchecked information.

But overall I don't regret my decision. The bank now has a new software which sucks big time. I was on a few occasions unable to access my money (ATM, online, bank office), so I don't think this is a bank that I could trust.


First Investment Bank, you were one of the best, now you're one of the worst.

# Thursday, May 08, 2008

What to do when most e-banking interfaces suck?

In a previous post (here) I spoke about having trouble with e-banking software of my bank.

There is a pretty simple solution - the online payment operator - epay.bg. It also can do bank transfers, so it's perfect for the task.

Epay can work with almost all bank cards, it's cheap, it's user-friendly, it's reliable. It's the perfect solution.
One minor drawback - it can't check balance, because for sometime now most banks don't support that feature for epay :(

Still I'm going to use it. I can check my balance using the e-banking app.

What not to do when you're a bank

My primary bank is First Investment Bank.
I chose a quite a while ago because it had the reputation of a bank that was the first in everything.

It's e-banking was uncomparable with the competitition - outrageously ugly, but accepted smartcards and did all I wanted it to do.

Now it's getting different - they changed their system with a new one. Something called FlexCube. Weirdly enough owned by Oracle.

From internal sources I know that the new system sucks and they failed to deploy it for more than a year. And when they finally made it last week during the weekend - my bank card was not working, meaning me without access to my money just before I went to Serbia. I had to take a loan to be able to go - not a pleasant thing to do.

So about the new e-banking interface - it sucks, all my preferences and beneficients are gone. It's ugly and hard to learn.

So I'm looking for a new bank with a decent e-banking services.

I have experience with SG Expressbank and Postbank - they suck too.

Update: the comments following that post reminded me of a story:
I was in the Netherlands. Once talking to one of the guys we discussed how much cash does each of us carry. I did carry a lot, he counted on the cards he had. My case: bank cards don't work on the road, on the street, they can fail, cash cannot fail.

Later that week:
There was this friend with which we drank quite a few drinks and on the way back to the hotel (I was in an apartment, the friend in a hotel) they said the employer forgot to pay the room, so it couldn't be used. We tried all the credit/debit cards we had - no luck - none of them worked. He had to sleep at my place. Cash is bulletproof !

# Tuesday, May 06, 2008

Srbija

I spent a couple of days in Serbia. Pictures here.

Overall I was surprised by what I saw - although they are not a rich country, its visible that they are situated closer than us to the more developed countries.
They don't speed on the road, it's clean and nice and green and ordered, people are really polite, roads are so much better than the Bulgarian ones.
Overall they are more advanced than we are.


# Friday, May 02, 2008

EJB Exception wrapping, commiting broken transactions, resource handling in finally statement - overridding thrown exceptions

In this piece of code the task is to override system exceptions (JPA, JTA exceptions) with application exceptions:

try {
    transaction.begin();
    bm(); //business method
} catch (PersistenceException) {
    //rewrite persistence exception and throw it     (1)
} finally {
    try {
        transaction.commit();
    } catch (RollbackException re) {
       if( re.getCause() instanceof PersistenceException ) rewrite
       else // THROW SOME DEFAULT EXCEPTION          (2)
    }
}



The rewriting of PersistenceException (PE) is straightforward.
It could come from the business method (bm()) and from commit().
When it comes from commit() it is wrapped in RollbackException. Thus the if.

Unfortunately if PE is raised from the bm(), it is also raised from the commit().

So if I throw an exception at (1), it gets overridden in (2). As simple as that. Because of the finally's ability to override results (OOP got messy here).

So what should be fixed?
First, at (2) I shouldn't throw any exception.

Second, I'm thinking of checking the result of bm() - if an exception, don't call commit(), but rollback().
Sounds right.

# 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.