Wednesday, September 30, 2009

got an javax.jdo.JDOFatalUserException ?

I was experimenting with junit test in combination with the JDO bundled with google app-engines java framwork when I got this message: "javax.jdo.JDOFatalUserException: No PersistenceManagerFactory configurable via properties resource "" or no named PMF or persistence unit named "" found."

This was resolved by replacing
pmf = JDOHelper.getPersistenceManagerFactory();
with
pmf = JDOHelper.getPersistenceManagerFactory("transactions-optional");

Duh.

Monday, September 21, 2009

bug in UUID.randomUUID()

Just a curiosity: I was investigating the excellent function in java.util.UUID to generate an unique ID for my application. While I was browsing the source code, I found that there is a bug here :)

from java.util.UUID:
public static UUID randomUUID() {
....
UUID result = new UUID(randomBytes);
return new UUID(randomBytes);
}

See? UUID result is created, but never used. Seems like this bug was discovered in 2004, but remains unfixed in java 6!!

Tuesday, September 15, 2009

Find the location of your classfile

There are many reasons for tring to find what location your java class is loaded from. E.g a big jee server with many apps and conflicting versions of libraries (read: a mastodont of a Websphere server)...

Here is the code that has saved many a day for me: