Monday, September 24, 2007

Hibernate, antlr and Class loading issues

Hibernate uses HQL(Hibernate Query Language) for generating Object-Oriented queries.  Hence for this purposes ships a specific version of antlr.jar along with the Hibernate. Most of the App servers use antlr to generate the Query Language for the CMP beans. In this case, it is quite possible that the two versions of antlr are different. The difference in versions kicks in some of the exception messages when you try to access the application. Most of the time, the exception is reported in the HQLToken class.

In some cases, ClassNotFound/NoClassDef exceptions are also reported as the global library file is trying to access the Applications WEB-INF/classes or WEB-INF/lib folders.

To resolve it, the easiest option is to remove the version shipped with App Server(Please note that most of the App Server support personnel refuse to assist if the folder structure/folders are altered in the server installation).  In case you are not using any components that use Container Managed Persistence, the above work around works fine.  The problems kick in when any of your component tries to use Container Managed Persistence. Also, to make sure that you get proper support from your App Server vendor, the above approach should not be followed.

So what should be done?

To fix the issues, the class load/search/scope functionalty of the App server needs to be modified. The classes in the WEB-INF/classes or WEB-INF/lib folders should be loaded/searched prior to the global ones.

Fortunately most of the Application servers provide a way to change to such classloading functionality. Following is the consolidated list for the App Servers:

Pramati Server:

Add the following tag after <module-name>  in the generated pramati-j2ee-server.xml file for the application under the <web-module> element:






Thursday, September 13, 2007


Are you one of those people who spend good amount of time publishing lot of posts and transferring photographs to one of your sites such as Flickr? Then you should check out Flock. This is very nice little browser(Of course a free one!). This remembers your account details and would post it to your blog/site for you. More details are here

If you are trying to upload Pics of yours to share it with your friends, then you are wasting your time and bandwidth in uploading the pics. Just download
Dekoh and start sharing the content from your desktop with fine grained control over what you share..

Want to know where your class is picked up from?

I safely assume that every one working on Java/J2EE platform must have come across class loading issues. Some (like Hrish) have the knack to crack them very efficiently. Some, like me, grope when trying to figure out the problem. Java says the first class it encounters in the classpath is picked up and the other versions of the same class later in the classpath are ignored. That sounds pretty simple. However, in some cases, jars contain manifest files pointing to various other jar files/locations. In such cases, it becomes very difficult to check where the class is being loaded from, unless you have good amount of patience to perform a search in TextPad and go through all the results for possible class loading issues. There have been few annoying situations because of the wrong class files picked up from the class path.

Here is the best way I use to figure out from which jar the class is being picked up. Start the java program with -verbose switch and it will print out the class being loaded and the jar/location from where it is being picked up. Sounds simple right? Yeah, but one caveat is, this would work only with Tiger(JDK5) version onwards. Good luck in your classloading issues, if any.

PS: Want to know the fancy names for various Java versions? Click here

Wednesday, September 12, 2007

JVM options for HP Java SDK

Its been long time that I actually worked with HP Java(even though for very short duration). Had one installation running on HP-Itanium machine which uses HP-Java. We wanted to turn on few JVM options for some analysis. Here is complete list of JVM options that are supported on HP Java. Its good to see HP-Java supporting few of the Sun non Standard JVM options as such.

Going Dutch

Any one who goes out to lunch with colleagues might have heard about this term. Today, I was having lunch with one of my good friend Bharani and suddenly this word popped up in our conversation. We both being avid fans of word origin stories, couldn't figure out how this was coined. Given by the name, could guess that it was something related to Dutch but could make no progress. You can check out the phrase on Wikipedia here. Well.. do not be disappointed that this has a negative meaning. As long as it does not hurt your pocket, it is good.