当我在JBoss AS 7中部署我的工作war文件时,我得到了以下异常
11:59:11,090 WARN [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015893: Encountered invalid class name 'com.sun.jersey.server.impl.model.parameter.multivalued.StringReaderProviders$StringConstructor' for service type 'com.sun.jersey.spi.StringReaderProvider' 11:59:11,091 WARN [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015893: Encountered invalid class name 'com.sun.jersey.server.impl.model.parameter.multivalued.StringReaderProviders$DateProvider' for service type 'com.sun.jersey.spi.StringReaderProvider' 11:59:11,092 WARN [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015893: Encountered invalid class name 'com.sun.jersey.server.impl.model.parameter.multivalued.JAXBStringReaderProviders$RootElementProvider' for service type 'com.sun.jersey.spi.StringReaderProvider' 11:59:11,923 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC00001: Failed to start service jboss.deployment.unit."myimpl.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."myimpl.war".POST_MODULE: Failed to process phase POST_MODULE of deployment "myimpl.war" at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final] at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA] at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA] at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_37] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_37] at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_37] Caused by: java.lang.NoClassDefFoundError: org/hibernate/exception/ConstraintViolationException at java.lang.Class.getDeclaredConstructors0(Native Method) [rt.jar:1.6.0_37] at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389) [rt.jar:1.6.0_37] at java.lang.Class.getConstructor0(Class.java:2699) [rt.jar:1.6.0_37] at java.lang.Class.getConstructor(Class.java:1657) [rt.jar:1.6.0_37] at org.jboss.as.web.deployment.jsf.JsfManagedBeanProcessor.deploy(JsfManagedBeanProcessor.java:108) at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final] ... 5 more Caused by: java.lang.ClassNotFoundException: org.hibernate.exception.ConstraintViolationException from [Module "deployment.myimpl.war:main" from Service Module Loader] at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.1.GA] at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA] at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.1.GA] at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423) [jboss-modules.jar:1.1.1.GA] at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.1.GA] at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.1.GA] ... 11 more 11:59:11,938 INFO [org.jboss.as] (MSC service thread 1-7) JBAS015951: Admin console listening on http://127.0.0.1:9990 11:59:11,938 ERROR [org.jboss.as] (MSC service thread 1-7) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 72380ms - Started 1402 of 1548 services (1 services failed or missing dependencies, 136 services are passive or on-demand) 11:59:11,939 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "myimpl.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"myimpl.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"myimpl.war\".POST_MODULE: Failed to process phase POST_MODULE of deployment \"myimpl.war\""}} 11:59:12,036 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015877: Stopped deployment myimpl.war in 95ms 11:59:12,038 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report JBAS014777: Services which failed to start: service jboss.deployment.unit."myimpl.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."myimpl.war".POST_MODULE: Failed to process phase POST_MODULE of deployment "myimpl.war" 11:59:12,040 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"myimpl.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"myimpl.war\".POST_MODULE: Failed to process phase POST_MODULE of deployment \"myimpl.war\""}}}}
我认为默认情况下JBoss AS 7支持在启动时将hibernate jar添加到classpath中(因为hibernate模块已经在JBoss AS7中可用)。我在hibernate-core-4.0.1.Final.jar(在'modules \ org \ hibernate \ main'文件夹结构下)找到了 ConstraintViolationException 类。那么为什么会出现 NoClassDefFoundError ?
请注意,我没有使用maven进行依赖性解析。对于依赖性解析,我手动将jar文件放入myimpl.war \ WEB-INF \ lib
无论如何,我在WEB-INF \ lib目录中添加了hibernate(hibernate3.jar)的jar,之后出现了一些新的异常,如下所示
12:51:19,146 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC00001: Failed to start service jboss.deployment.unit."myimpl.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."myimpl.war".POST_MODULE: Failed to process phase POST_MODULE of deployment "myimpl.war" at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final] at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA] at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA] at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_37] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_37] at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_37] Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011232: Only one JAX-RS Application Class allowed. com.sun.jersey.api.core.WebAppResourceConfig com.sun.jersey.api.core.ResourceConfig com.sun.jersey.api.core.ClassNamesResourceConfig com.sun.jersey.api.core.ScanningResourceConfig com.sun.jersey.api.core.ClasspathResourceConfig com.sun.jersey.api.core.DefaultResourceConfig com.sun.jersey.api.core.PackagesResourceConfig com.sun.jersey.server.impl.application.DeferredResourceConfig com.sun.jersey.api.core.ApplicationAdapter at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.scan(JaxrsScanningProcessor.java:209) at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.deploy(JaxrsScanningProcessor.java:105) at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final] ... 5 more
请简要介绍一下如何解决这个问题
答案 0 :(得分:1)
你必须在jboss部署结构xml文件中添加hibernate jar的依赖项。试试并告诉我结果
答案 1 :(得分:1)
通过从stanalone.xml中删除以下两行来解决org.jboss.as.server.deployment.DeploymentUnitProcessingException
<extension module="org.jboss.as.jaxrs"/>
<subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/>
hibernate NoClassDefFoundError
也是由于hibernate jar版本问题造成的。在war文件中,我正在使用hibernate3.jar和JBoss AS7的hibernate模块目录,其中包含一个hibernate 4.0.1版本
答案 2 :(得分:1)
检查类路径
问题-java.lang.NoClassDefFoundError
根本原因:环境变量部分
中设置的Java路径不正确解决方案:设置正确的JAVA_HOME路径
步骤 - &gt;环境变量设置(我的Comp-Right Click - &gt; Properties-&gt; Env Variable-&gt; Advance Tab - &gt; Variable)
创建新的JAVA_HOME环境变量。
JAVA_HOME .; C:\ Program Files(x86)\ Java \ jdk1.6.0_14
在PATH变量部分设置JAVA_HOME变量。
PATH%JAVA_HOME%\ bin
在CLASSPATH Variable
中设置JAVA_HOME变量CLASSPATH%JAVA_HOME%\ jre \ lib
重启系统
验证所有变量
echo%CLASSPATH%
echo%JAVA_HOME%
echo%PATH%
编译&amp;运行程序
答案 3 :(得分:1)
我同意sankar为jboss提供的hibernate模块添加explict依赖。添加依赖项的其他方法是通过META-INF下的MANIFEST文件。
下面的链接是关于Jboss ClassLoading和Dependencies的好文章。希望它有所帮助。
http://www.mastertheboss.com/jboss-as-7/jboss-as-7-classloading