Florent06
Florent06

Reputation: 988

NoClassDefFoundError with external project included - JBoss 7.1

I'm in charge of 2 projects at the same times. The first (A), is a library and the second (B) a Java EE project working on JBoss AS 7.1.

B needs libraries from A. Both of them are written using Eclipse Juno.

I managed to include the A project as a jar in the WEB-INF/lib folder. When I do "republish", A.jar is automatically compiled and included in the WEB-INF/lib folder.

But, when I want to load a page calling a library from A, I have a NoClassDefFoundError on the class from A.

Upvotes: 0

Views: 940

Answers (2)

Toni
Toni

Reputation: 1381

NOClassDefFoundError is thrown when the JVM or a ClassLoader instance tries to load a definition of a class and the proper definition can't be found in runtime.

So check if you've packaged an older (or wrong) version of the class in library A, different from the one needed by your B module (a typical example is when the class can be found, but it doesn't have the method definitions needed by the application caller).

On the other hand, take in mind that by default JBoss uses an unified classloader and Java Parent delegation, so although a library is deployed in several modules in the same JBoss instance, JBoss only loads one (sharing it between the modules), giving preference to the one included in the parent. This may lead to unexpected behaviour if the several modules must use different versions of the same library. So check as well, if you've several versions of the library A deployed in your JBoss instance.

Upvotes: 1

Jon Kartago Lamida
Jon Kartago Lamida

Reputation: 854

NoClassDefFoundError happened when the class is available in compile time but cannot be found in the runtime. If you have make sure that the A.jar have been copied to WEB-INF/lib properly then other suspect might be the missing class is not inside that jar. Try to see inside A.jar e.g by extracting it and see whether the missing class is inside it.

Upvotes: 1

Related Questions