java JBOSS 7 - Spring ContextLoaderListener ClassNotFoundException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7560990/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JBOSS 7 - Spring ContextLoaderListener ClassNotFoundException
提问by Robert Niestroj
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)
我正在尝试将我的 JBOSS 5.1 应用程序迁移到 JBOSS 7.0.2。在管理控制台中,我选择部署 -> 添加内容和我的 .war 并尝试启用它。我已经解决了一些问题,但无法弄清楚这个:(总之,最后是长)
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:
我复制到JBOSS7\standalone\lib\
以下文件:
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?
我读过这个:https: //docs.jboss.org/author/display/AS7/How+do+I+migrate+my+application+from+AS5+or+AS6+to+AS7 (调试和解决 ClassNotFoundExceptions 和NoClassDefFoundErrors),但无法为我找到解决方案并且仍然遇到相同的错误。任何人都可以帮忙吗?
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.compute(EEClassConfigurationProcessor.java:141)
at org.jboss.as.ee.component.deployers.EEClassConfigurationProcessor.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.compute(EEClassConfigurationProcessor.java:139)
... 11 more
回答by anirudh bhatnagar
JBoss AS 7 does class-loading in a diff way.
JBoss AS 7 以不同的方式加载类。
All classes in the WAR are loaded with the same class loader. This means classes packaged in the WEB-INF/lib are treated the same as classes in WEB-INF/classes. Hence it works for you.
WAR 中的所有类都使用相同的类加载器加载。这意味着打包在 WEB-INF/lib 中的类被视为与 WEB-INF/classes 中的类相同。因此它对你有用。
But as you have said correctly your WEB-INF/lib is bloated.This would not be the correct way.
但是正如您所说的那样,您的 WEB-INF/lib 是臃肿的。这不是正确的方法。
You would need to make a module : Goto modules folder, make folder structure with main folder and put your jar and modules.xml with entries in it. Something like :
您需要创建一个模块:转到模块文件夹,使用主文件夹创建文件夹结构,并将带有条目的 jar 和 modules.xml 放入其中。就像是 :
<main-class name="org.jboss.msc.Version"/>
<resources>
<resource-root path="jboss-msc-1.0.1.GA.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.modules"/>
<!-- Optional deps -->
<module name="javax.inject.api" optional="true"/>
<module name="org.jboss.threads" optional="true"/>
<module name="org.jboss.vfs" optional="true"/>
</dependencies>
You would also need to update MANIFEST as well. Details are here : https://docs.jboss.org/author/display/MODULES/Module+descriptors
您还需要更新 MANIFEST。详细信息在这里:https: //docs.jboss.org/author/display/MODULES/Module+descriptors
回答by duffymo
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.
我不会将那些 JAR 放在那个目录中。在您的 WAR 文件的 WEB-INF/lib 中尝试它们。类加载器会在那里找到它们。
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.
您需要了解所有 Java EE 应用服务器都使用类加载器的层次结构:引导程序、服务器、应用程序。JBoss 在需要的时候没有找到那个类。
回答by Adisesha
There is a major change Jboss 7 when compared to previous versions.If you want to access any libraries outside your war file, it should be installed as module. Check https://docs.jboss.org/author/display/MODULES/IntroductionIn this case you should install Spring as module and specify the name of the module as dependency in your application's manifest file(check Manifest module information)
与以前的版本相比,Jboss 7 有一个重大变化。如果你想访问你的 war 文件之外的任何库,它应该作为模块安装。检查https://docs.jboss.org/author/display/MODULES/Introduction在这种情况下,您应该将 Spring 作为模块安装,并在应用程序的清单文件中指定模块的名称作为依赖项(检查清单模块信息)