部署由maven overlay创建的war文件时的java.lang.NoClassDefFoundError

时间:2013-02-27 16:56:43

标签: maven classloader maven-3 jboss7.x noclassdeffounderror

我是由Maven构建的战争文件,使用其他战争叠加作为依赖项... 建成是成功的。

但是在部署到Jboss时,我收到以下错误:

11:27:49,054 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-1) .... nested exception is java.lang.NoClassDefFoundError: org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor
        at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:281) [spring-context-3.2.1.RELEASE.jar:3.2.1.RELEASE]
        at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242) [spring-context-3.2.1.RELEASE.jar:3.2.1.RELEASE]
        ........

所以我对java.lang.NoClassDefFoundErrorAnnotationMetadataReadingVisitor ...基于异常,我假设该类在类路径上出现不止一次。

我已经确认类路径上存在org.springframework.core.type.classreading.AnnotationMetadataReadingVisitor(在WEB-INF\lib\spring-core-3.2.1.RELEASE.jar中的war文件中)。

但据我所知,它是我的类路径中唯一包含该类的jar。

知道我在这里缺少什么吗?

以下是我正在尝试部署的战争WEB-INF\lib的完整内容:

activemq-all-5.5.1.jar
ant-1.7.0.jar
ant-launcher-1.7.0.jar
antlr-2.7.7.jar
antlr-3.3.jar
antlr-runtime-3.3.jar
aopalliance-1.0.jar
aspectjweaver-1.7.1.jar
axiom-api-1.2.12.jar
axiom-dom-1.2.12.jar
axiom-impl-1.2.12.jar
axis2-1.6.1.jar
axis2-adb-1.6.1.jar
axis2-adb-codegen-1.6.1.jar
axis2-ant-plugin-1.6.1.jar
axis2-clustering-1.6.1.jar
axis2-codegen-1.6.1.jar
axis2-corba-1.6.1.jar
axis2-fastinfoset-1.6.1.jar
axis2-java2wsdl-1.6.1.jar
axis2-jaxbri-1.6.1.jar
axis2-jaxws-1.6.1.jar
axis2-jibx-1.6.1.jar
axis2-json-1.6.1.jar
axis2-kernel-1.6.1.jar
axis2-metadata-1.6.1.jar
axis2-mtompolicy-1.6.1.jar
axis2-saaj-1.6.1.jar
axis2-transport-http-1.6.1.jar
axis2-transport-local-1.6.1.jar
axis2-xmlbeans-1.6.1.jar
bcel-5.1.jar
blitzer-1.0.9.jar
c3p0-0.9.1.1.jar
camel-core-2.4.0.jar
camel-xstream-2.4.0.jar
cdjai-1.0.jar
commons-beanutils-1.7.0.jar
commons-cli-1.2.jar
commons-codec-1.3.jar
commons-collections-3.1.jar
commons-dbcp-1.4.jar
commons-digester-1.8.jar
commons-fileupload-1.2.1.jar
commons-httpclient-3.1.jar
commons-io-1.3.2.jar
commons-lang-2.5.jar
commons-logging-1.1.1.jar
commons-logging-api-1.1.jar
commons-management-1.0.jar
commons-net-3.1.jar
commons-pool-1.5.4.jar
displaytag-1.2.jar
displaytag-export-poi-1.2.jar
drools-compiler-5.3.0.Final.jar
drools-core-5.3.0.Final.jar
ecj-3.5.1.jar
el-api-2.2.jar
el-impl-2.2.jar
FastInfoset-1.2.7.jar
freemarker-2.3.13.jar
geronimo-activation_1.1_spec-1.0.2.jar
geronimo-annotation_1.0_spec-1.1.jar
geronimo-javamail_1.4_spec-1.6.jar
geronimo-jaxws_2.2_spec-1.0.jar
geronimo-jta_1.1_spec-1.1.jar
geronimo-saaj_1.3_spec-1.0.1.jar
geronimo-stax-api_1.0_spec-1.0.1.jar
geronimo-ws-metadata_2.0_spec-1.1.2.jar
httpcore-4.0.jar
itext-1.3.jar
javaee-api-5.0-2.jar
javax.inject-1.jar
jaxb-api-2.1.jar
jaxb-impl-2.1.7.jar
jaxb-xjc-2.1.7.jar
jaxen-1.1.1.jar
jaxws-tools-2.1.3.jar
jboss-j2se-200504122039.jar
jcl104-over-slf4j-1.4.2.jar
jettison-1.2.jar
jibx-bind-1.2.jar
jibx-run-1.2.jar
jsp-api-2.1.jar
jsr311-api-1.0.jar
jta-1.1.jar
juli-6.0.16.jar
junit-4.8.2.jar
knowledge-api-5.3.0.Final.jar
log4j-1.2.16.jar
mvel2-2.1.0.drools4.jar
neethi-2.0.1.jar
ognl-2.6.11.jar
ojdbc14-10.2.0.3.0.jar
p-my-web-app-legacy-1.0-SNAPSHOT-classes.jar
poi-3.2-FINAL.jar
primefaces-3.4.2.jar
quartz-2.0.2.jar
regexp-1.2.jar
servlet-api-2.5.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.4.2.jar
spring-aop-3.2.1.RELEASE.jar
spring-asm-3.1.4.RELEASE.jar
spring-aspects-3.2.1.RELEASE.jar
spring-beans-3.2.1.RELEASE.jar
spring-context-3.2.1.RELEASE.jar
spring-context-support-3.2.1.RELEASE.jar
spring-core-3.2.1.RELEASE.jar
spring-expression-3.2.1.RELEASE.jar
spring-instrument-3.2.1.RELEASE.jar
spring-jdbc-3.2.1.RELEASE.jar
spring-jms-3.2.1.RELEASE.jar
spring-orm-3.2.1.RELEASE.jar
spring-oxm-3.2.1.RELEASE.jar
spring-test-3.2.1.RELEASE.jar
spring-tx-3.2.1.RELEASE.jar
spring-web-3.2.1.RELEASE.jar
spring-webmvc-3.2.1.RELEASE.jar
standard-1.0.6.jar
stax-api-1.0.1.jar
stax2-api-3.0.1.jar
stringtemplate-3.2.1.jar
struts2-core-2.1.6.jar
struts2-dojo-plugin-2.2.3.1.jar
struts2-tiles-plugin-2.1.6.jar
tiles-api-2.0.6.jar
tiles-core-2.0.6.jar
tiles-jsp-2.0.6.jar
tiles-servlet-2.1.2.jar
tribes-6.0.16.jar
woden-api-1.0M9.jar
woden-impl-commons-1.0M9.jar
woden-impl-dom-1.0M9.jar
woodstox-core-asl-4.0.7.jar
wsdl4j-1.6.2.jar
wstx-asl-3.2.9.jar
xalan-2.7.0.jar
xml-resolver-1.2.jar
xmlbeans-2.3.0.jar
XmlSchema-1.4.7.jar
xpp3_min-1.1.4c.jar
xstream-1.3.1.jar
xwork-2.1.2.jar

2 个答案:

答案 0 :(得分:7)

所以你在这里遇到版本冲突

spring-aop-3.2.1.RELEASE.jar
spring-asm-3.1.4.RELEASE.jar
spring-aspects-3.2.1.RELEASE.jar
spring-beans-3.2.1.RELEASE.jar
spring-context-3.2.1.RELEASE.jar
spring-context-support-3.2.1.RELEASE.jar
spring-core-3.2.1.RELEASE.jar
spring-expression-3.2.1.RELEASE.jar
spring-instrument-3.2.1.RELEASE.jar
spring-jdbc-3.2.1.RELEASE.jar
spring-jms-3.2.1.RELEASE.jar
spring-orm-3.2.1.RELEASE.jar
spring-oxm-3.2.1.RELEASE.jar
spring-test-3.2.1.RELEASE.jar
spring-tx-3.2.1.RELEASE.jar
spring-web-3.2.1.RELEASE.jar
spring-webmvc-3.2.1.RELEASE.jar

其他库是3.2.1,spring-asm是3.1.4。 一般来说,弹簧罐应该是相同的版本。

Spring-asm库捆绑在3.2系列(source)的spring-core中:

  

截至3.2 M2 [..]我们已经取消了专用的spring-asm jar   在M2中支持直接包含org.springframework.asm类   在spring-core。

所以在这种情况下,应该将其排除在外。

答案 1 :(得分:0)

而且,为了拼出这个(对于我将来),我必须将{ transitive = false }添加到我的BuildConfig.groovy文件中。

E.g。

grails.project.dependency.resolution = {
    plugins {
        ...
        compile(":spring-security-core:2.0-RC2")
        compile(":spring-security-facebook:0.15.1-CORE2"){ transitive = false }
        ...
    }
}