Search code examples
javaclassloaderwarnoclassdeffounderrorear

NoClassDefFoundError in a WAR in an EAR


I have an EAR that has a WAR inside, which has a jar inside it's WEB-INF/lib/. However, the class in that jar cannot be located (throws NoClassDefFoundError). I've verified that the class is indeed in that jar by doing javap -classpath

Any ideas why?

I'm on glassfish.


Solution

  • I figured it out. For some strange reason, the classes being loaded failed to get loaded due to some missing classes. i.e. I have a ClassA and it was loading ClassB. ClassB depends on ClassC. But since ClassC was not in my classpath, ClassB's class was not properly loaded. Thus, accessing ClassB from ClassA threw NoClassDefFoundError.