Search code examples
jbossclassloaderclassnotfoundexception

ClassLoader can't find class that is present in .war's WEB-INF/lib folder


So pretty suddenly, after updating some unrelated JNDI properties and after the deployments rebooted, I'm getting an error on one of them:

[TRACE] (ServerService Thread Pool -- 79) ..camel.util.ObjectHelper (485) Cannot load class: ImportantClass 
using classloader: ModuleClassLoader for Module "deployment.my-war-deployment.war" from Service Module Loader: 
java.lang.ClassNotFoundException: ImportantClass 
from [Module "deployment.my-war-deployment.war" from Service Module Loader]

The error isn't triggered on deploying, but when the class is first needed.

When inspecting my .war, the WEB-INF/lib folder contains my-jar.jar which contains the ImportantClass class file. If it's of any importance: my-jar.jar is one of the modules of my second deployment, my-ear-deployment.ear, but the module is included in my .war during compile time. I also tried it without <scope>compile</scope> in the POM on the needed module and it had the same result.

Any clues on what went wrong or how to fix it? Is it using the wrong class loader, since the need class is inside a .jar? I'm no big DevOps expert unfortunately. We're using JBoss EAP 7.2.


Solution

  • I found the problem, which was totally unrelated to the shown error message (at least from my PoV):

    My .war was looking for a nonexistent system property. I have no idea how that resulted in the ClassLoader exception though, but I'm happy to have it fixed.