Search code examples
javaspringjbossclassnotfoundexceptionjboss7.x

JBOSS 7 - Spring ContextLoaderListener ClassNotFoundException


im trying to migrate my JBOSS 5.1 application to JBOSS 7.0.2. In admin console i select deployments -> add content and my .war and try to enable it. I already resolved some problems, but cant figure out this one: (in short, in long at the end)

Caused by: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener from [Module "deployment.ZaprogsProject.war:main" from Servic
e Module Loader]

I copied to JBOSS7\standalone\lib\ the following files:

spring-aop-3.0.5.RELEASE.jar
spring-asm-3.0.5.RELEASE.jar
spring-beans-3.0.5.RELEASE.jar
spring-context-3.0.5.RELEASE.jar
spring-context-support-3.0.5.RELEASE.jar
spring-core-3.0.5.RELEASE.jar
spring-expression-3.0.5.RELEASE.jar
spring-jdbc-3.0.5.RELEASE.jar
spring-orm-3.0.5.RELEASE.jar
spring-test-3.0.5.RELEASE.jar
spring-tx-3.0.5.RELEASE.jar
spring-web-3.0.5.RELEASE.jar
spring-webmvc-3.0.5.RELEASE.jar

I have read this: https://docs.jboss.org/author/display/AS7/How+do+I+migrate+my+application+from+AS5+or+AS6+to+AS7 (Debug and resolve ClassNotFoundExceptions and NoClassDefFoundErrors) but cant find a solution for me and still getting the same error. Can anyone help?

22:19:12,091 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.deployment.unit."ZaprogsProject.war".INSTALL: o
rg.jboss.msc.service.StartException in service jboss.deployment.unit."ZaprogsProject.war".INSTALL: Failed to process phase INSTALL of deployment "ZaprogsProject
.war"
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [:1.7.0]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.7.0]
        at java.lang.Thread.run(Thread.java:722) [:1.7.0]
Caused by: java.lang.RuntimeException: Failed to load class org.springframework.web.context.ContextLoaderListener
        at org.jboss.as.ee.component.deployers.EEClassConfigurationProcessor$1.compute(EEClassConfigurationProcessor.java:141)
        at org.jboss.as.ee.component.deployers.EEClassConfigurationProcessor$1.compute(EEClassConfigurationProcessor.java:122)
        at org.jboss.as.ee.component.LazyValue.get(LazyValue.java:40)
        at org.jboss.as.ee.component.EEApplicationDescription.getClassConfiguration(EEApplicationDescription.java:183)
        at org.jboss.as.ee.component.ComponentDescription.createConfiguration(ComponentDescription.java:153)
        at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:70)
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
        ... 5 more
Caused by: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener from [Module "deployment.ZaprogsProject.war:main" from Servic
e Module Loader]
        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)
        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)
        at java.lang.Class.forName0(Native Method) [:1.7.0]
        at java.lang.Class.forName(Class.java:264) [:1.7.0]
        at org.jboss.as.ee.component.deployers.EEClassConfigurationProcessor$1.compute(EEClassConfigurationProcessor.java:139)
        ... 11 more

Solution

  • I would not put those JARs in that directory. Try them in your WAR file's WEB-INF/lib. The class loader will find them there.

    You need to understand that all Java EE app servers use a hierarchy of class loaders: bootstrap, server, application. JBoss wasn't finding that class when it needed to.