Eclipse: Run => NoClassDefFoundError for an interface when loading a class implementing it
Posted by Jakub Holý on April 21, 2006
I had quite a hard time trying to run the following code in Eclipse (CollectionUserType implements UserType):
The problem was:
Exception in thread “main” java.lang.NoClassDefFoundError: net/sf/hibernate/UserType
at java.lang.ClassLoader.findBootstrapClass(Native Method)
The strange thing was that I could define instances of both UserType and CollectionUserType so it was clear that the classes are available. The evident conclusion was that CollectionUserType is loaded by a special classloader that doesn’t have access to UserType.
Examining closely the Run Configuration I’ve discovered the cause: the location of CollectionUserType was among the Bootstrap Entries while the location of UserType was among User Entries. And since the bootstrap class loader is above other class loaders in the class loader hierarchy, it has no access to classes loaded by the subordinate class loaders (including UserType) while vice versa it’s all right.<
So the solution was to move the entry from Bootstrap Entries to User Entries.
Sorry, the comment form is closed at this time.