java.lang.NoClassDefFoundError:org / apache / cxf / jaxrs / impl / UriBuilderImpl

时间:2014-09-09 23:01:57

标签: java maven soap weblogic cxf

我没有在我的代码中直接使用Apache CXF。我甚至没有将它作为依赖。现在升级到WebLogic 12c时,我遇到了这个异常。我之前得到了一些与提取soap消息体相关的其他错误,我在下面添加了saaj依赖项之后就解决了这个问题。

        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-bundle-jaxrs</artifactId>
            <version>${cxf-version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-api</artifactId>
            <version>${cxf-version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>${cxf-version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-ws-policy</artifactId>
            <version>${cxf-version}</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.messaging.saaj</groupId>
            <artifactId>saaj-impl</artifactId>
            <version>1.3.15</version>
        </dependency>
        <dependency>
            <groupId>javax.xml.soap</groupId>
            <artifactId>saaj-api</artifactId>
            <version>1.3.5</version>
        </dependency>

错误:

java.lang.NoClassDefFoundError: org/apache/cxf/jaxrs/impl/UriBuilderImpl
        at org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl.createUriBuilder(RuntimeDelegateImpl.java:89)
        at javax.ws.rs.core.UriBuilder.newInstance(UriBuilder.java:69)
        at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:80)
        at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:99)
        at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:649)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341)
        at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
        at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3367)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3333)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
        at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
        at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2220)
        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2146)
        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2124)
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1564)
        at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)
>

依赖树:

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ myapp1 ---
[INFO] mypackage.myapp:myapp1:war:4.4.1.158-SNAPSHOT
[INFO] +- mypackage.integration:integration-bpm:jar:4.4.1.158-SNAPSHOT:compile
[INFO] |  +- mypackage.integration:integration-http:jar:4.4.1.158-SNAPSHOT:compile
[INFO] |  |  \- org.apache.cxf:cxf-rt-frontend-jaxrs:jar:2.7.7:compile
[INFO] |  |     \- org.apache.cxf:cxf-rt-bindings-xml:jar:2.7.7:compile
[INFO] |  +- xalan:xalan:jar:2.7.1:compile
[INFO] |  |  \- xalan:serializer:jar:2.7.1:compile
[INFO] |  +- xerces:xercesImpl:jar:2.9.0:provided
[INFO] |  +- org.hibernate:hibernate-core:jar:3.6.10.Final:compile
[INFO] |  |  +- antlr:antlr:jar:2.7.6:compile
[INFO] |  |  +- commons-collections:commons-collections:jar:3.1:compile
[INFO] |  |  +- org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile
[INFO] |  |  +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final:compile
[INFO] |  |  \- javax.transaction:jta:jar:1.1:compile
[INFO] |  +- org.hibernate:hibernate-entitymanager:jar:3.6.10.Final:compile
[INFO] |  |  \- javassist:javassist:jar:3.12.0.GA:compile
[INFO] |  \- org.apache.commons:commons-lang3:jar:3.1:compile
[INFO] +- mypackage.integration:integration-core:jar:4.4.1.158-SNAPSHOT:compile
[INFO] |  +- org.springframework:spring-web:jar:3.0.5.RELEASE:compile
[INFO] |  +- org.safehaus.jug:jug:jar:asl:2.0.0:compile
[INFO] |  +- net.sf.dozer:dozer:jar:5.3.2:compile
[INFO] |  |  +- commons-beanutils:commons-beanutils:jar:1.8.3:compile
[INFO] |  |  \- commons-lang:commons-lang:jar:2.5:compile
[INFO] |  +- net.sf.json-lib:json-lib:jar:jdk15:2.3:compile
[INFO] |  |  \- net.sf.ezmorph:ezmorph:jar:1.0.6:compile
[INFO] |  +- xom:xom:jar:1.1:compile
[INFO] |  |  +- xerces:xmlParserAPIs:jar:2.6.2:provided
[INFO] |  |  \- jaxen:jaxen:jar:1.1.1:compile
[INFO] |  +- org.aspectj:aspectjtools:jar:1.5.4:compile
[INFO] |  +- cglib:cglib:jar:2.2.2:compile
[INFO] |  +- gov.hhs.healthit.nhin.connect:common-types:jar:2.4:compile
[INFO] |  +- commons-codec:commons-codec:jar:1.6:compile
[INFO] |  \- commons-io:commons-io:jar:2.0.1:compile
[INFO] +- mypackage.integration:integration-test:jar:4.4.1.158-SNAPSHOT:compile
[INFO] |  +- xmlunit:xmlunit:jar:1.3:test
[INFO] |  \- eviware:maven-soapui-plugin:jar:4.5.1:test
[INFO] |     +- org.apache.maven:maven-plugin-api:jar:2.0:test
[INFO] |     +- eviware:soapui:jar:4.5.1:test
[INFO] |     +- javax.activation:activation:jar:1.1:compile
[INFO] |     +- javax.mail:mail:jar:1.4:compile
[INFO] |     +- commons-ssl:not-yet-commons-ssl:jar:0.3.11:test
[INFO] |     +- commons-cli:commons-cli:jar:1.0:test
[INFO] |     +- json:json-lib:jar:2.2.2-jdk15:test
[INFO] |     +- ezmorph:ezmorph:jar:1.0.5:test
[INFO] |     +- swingx:swingx:jar:soapui:test
[INFO] |     +- groovy:groovy-all:jar:1.8.0:test
[INFO] |     +- rhino:js:jar:1.7R2:test
[INFO] |     +- jetty:jetty:jar:6.1.26:test
[INFO] |     +- jetty:jetty-util:jar:6.1.26:test
[INFO] |     +- jetty:servlet-api:jar:2.5-20081211:test
[INFO] |     +- net-components:netcomponents:jar:1.3.8a:test
[INFO] |     +- xmlbeans:xbean:jar:fixed-2.4.0:test
[INFO] |     +- xmlbeans:xbean_xpath:jar:2.4.0:test
[INFO] |     +- xmlbeans:xmlpublic:jar:2.4.0:test
[INFO] |     +- xmlbeans:jsr173:jar:xmlbeans-2.4.0:test
[INFO] |     +- eviware:soapui-xmlbeans:jar:4.5.1:test
[INFO] |     +- eviware:policy-xmlbeans:jar:1.5:test
[INFO] |     +- eviware:soap-xmlbeans:jar:1.2:test
[INFO] |     +- eviware:wadl-xmlbeans:jar:1.1:test
[INFO] |     +- eviware:j2ee-xmlbeans:jar:1.4:test
[INFO] |     +- eviware:ext-xmlbeans:jar:1.2:test
[INFO] |     +- saxon:saxon:jar:9.1.0.8j:test
[INFO] |     +- saxon:saxon-dom:jar:9.1.0.8j:test
[INFO] |     +- xml-security:xmlsec:jar:1.4.3:test
[INFO] |     +- opensaml:opensaml:jar:1.1:test
[INFO] |     +- wss4j:wss4j:jar:1.5.8:test
[INFO] |     +- bouncycastle:bcprov-jdk15:jar:144:test
[INFO] |     +- jtidy:jtidy:jar:r872-jdk15:test
[INFO] |     +- javax.jms:jms:jar:1.1:test
[INFO] |     +- hermesjms:hermes:jar:1.14:test
[INFO] |     +- amf:flex-messaging-common:jar:1.0:test
[INFO] |     +- amf:flex-messaging-core:jar:1.0:test
[INFO] |     +- amf:flex-messaging-opt:jar:1.0:test
[INFO] |     +- amf:flex-messaging-proxy:jar:1.0:test
[INFO] |     +- amf:flex-messaging-remoting:jar:1.0:test
[INFO] |     +- thoughtworks:xstream:jar:1.3.1:test
[INFO] |     +- net.sourceforge.htmlunit:htmlunit:jar:2.7:test
[INFO] |     |  \- commons-httpclient:commons-httpclient:jar:3.1:compile
[INFO] |     +- org.w3c.css:sac:jar:1.3:test
[INFO] |     +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.7:test
[INFO] |     +- net.sourceforge.cssparser:cssparser:jar:0.9.5:test
[INFO] |     +- net.sourceforge.nekohtml:nekohtml:jar:1.9.14:test
[INFO] |     +- fife:rsyntaxtextarea:jar:1.3.4:test
[INFO] |     +- org.apache.httpcomponents:httpclient:jar:4.1.1:test
[INFO] |     +- org.apache.httpcomponents:httpmime:jar:4.1.1:test
[INFO] |     +- org.apache.httpcomponents:httpclient-cache:jar:4.1.1:test
[INFO] |     +- org.apache.httpcomponents:httpcore:jar:4.1.1:test
[INFO] |     +- org.apache.httpcomponents:httpcore-nio:jar:4.1.1:test
[INFO] |     \- org.samba.jcifs:jcifs:jar:1.2.9:test
[INFO] +- mypackage.myapp:myapp_common:jar:4.4.1.158-SNAPSHOT:compile
[INFO] |  +- mypackage.integration:integration-jms:jar:4.4.1.158-SNAPSHOT:compile
[INFO] |  |  \- ca.uhn.hapi:hapi-base:jar:0.6:compile
[INFO] |  \- mypackage.integration:integration-feed:jar:4.4.1.158-SNAPSHOT:compile
[INFO] +- mypackage.myapp:myapp_mock:jar:4.4.1.158-SNAPSHOT:compile
[INFO] |  +- mypackage.integration:integration-hl7:jar:4.4.1.158-SNAPSHOT:compile
[INFO] |  +- mypackage.myapp:myapp_bindings:jar:4.4.1.158-SNAPSHOT:compile
[INFO] |  \- mypackage.myapp:myapp_audit:jar:4.4.1.158-SNAPSHOT:compile
[INFO] +- org.springframework:spring-core:jar:3.0.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-asm:jar:3.0.5.RELEASE:compile
[INFO] |  \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.springframework:spring-expression:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-beans:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-aop:jar:3.0.5.RELEASE:compile
[INFO] |  \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-context:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:3.0.5.RELEASE:compile
[INFO] |  \- org.springframework:spring-jdbc:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-jms:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-context-support:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-core:jar:3.1.0.RC2:compile
[INFO] +- org.springframework.ws:spring-ws:jar:2.0.0-M1:compile
[INFO] +- org.springframework:spring-oxm:jar:3.0.5.RELEASE:compile
[INFO] +- com.sun.jersey:jersey-server:jar:1.8:compile
[INFO] |  +- asm:asm:jar:3.3.1:compile
[INFO] |  \- com.sun.jersey:jersey-core:jar:1.8:compile
[INFO] +- com.sun.jersey:jersey-client:jar:1.8:compile
[INFO] +- com.sun.jersey:jersey-json:jar:1.8:compile
[INFO] |  +- org.codehaus.jettison:jettison:jar:1.1:compile
[INFO] |  |  \- stax:stax-api:jar:1.0.1:compile
[INFO] |  +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile
[INFO] |  |  \- javax.xml.bind:jaxb-api:jar:2.2.2:compile
[INFO] |  |     \- javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO] |  +- org.codehaus.jackson:jackson-core-asl:jar:1.7.1:compile
[INFO] |  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.7.1:compile
[INFO] |  +- org.codehaus.jackson:jackson-jaxrs:jar:1.7.1:compile
[INFO] |  \- org.codehaus.jackson:jackson-xc:jar:1.7.1:compile
[INFO] +- com.sun.jersey.contribs:jersey-atom-abdera:jar:1.8:compile
[INFO] |  +- org.apache.abdera:abdera-parser:jar:1.0:compile
[INFO] |  |  +- org.apache.abdera:abdera-core:jar:1.0:compile
[INFO] |  |  |  +- org.apache.abdera:abdera-i18n:jar:1.0:compile
[INFO] |  |  |  \- org.apache.geronimo.specs:geronimo-activation_1.0.2_spec:jar:1.1:compile
[INFO] |  |  +- org.apache.ws.commons.axiom:axiom-impl:jar:1.2.5:compile
[INFO] |  |  |  \- org.apache.ws.commons.axiom:axiom-api:jar:1.2.5:compile
[INFO] |  |  +- org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0.1:compile
[INFO] |  |  \- org.codehaus.woodstox:wstx-asl:jar:3.2.6:runtime
[INFO] |  \- org.apache.abdera:abdera-extensions-json:jar:1.0:compile
[INFO] |     +- org.apache.abdera:abdera-server:jar:1.0:compile
[INFO] |     |  \- javax.servlet:servlet-api:jar:2.4:compile
[INFO] |     +- org.apache.abdera:abdera-extensions-main:jar:1.0:compile
[INFO] |     |  \- org.apache.abdera:abdera-client:jar:1.0:compile
[INFO] |     \- org.apache.abdera:abdera-extensions-html:jar:1.0:compile
[INFO] |        \- nu.validator.htmlparser:htmlparser:jar:1.0.5:compile
[INFO] +- com.sun.jersey:jersey-atom:jar:1.8:compile
[INFO] |  +- rome:rome:jar:0.9:compile
[INFO] |  \- jdom:jdom:jar:1.0:compile
[INFO] +- com.sun.jersey.contribs:jersey-multipart:jar:1.8:compile
[INFO] |  \- org.jvnet:mimepull:jar:1.4:compile
[INFO] +- com.sun.jersey.contribs:jersey-spring:jar:1.8:compile
[INFO] +- com.sun.jersey.contribs:jersey-guice:jar:1.8:compile
[INFO] |  +- javax.inject:javax.inject:jar:1:compile
[INFO] |  +- com.google.inject:guice:jar:3.0:compile
[INFO] |  \- com.google.inject.extensions:guice-servlet:jar:3.0:compile
[INFO] +- net.sf.saxon:saxon:jar:9.1.0.8:compile
[INFO] +- net.sf.saxon:saxon-dom:jar:9.1.0.8:compile
[INFO] +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  \- xml-apis:xml-apis:jar:1.0.b2:provided
[INFO] +- org.slf4j:slf4j-api:jar:1.6.1:compile
[INFO] +- org.slf4j:com.springsource.slf4j.org.apache.commons.logging:jar:1.6.1:runtime
[INFO] +- org.slf4j:com.springsource.slf4j.log4j:jar:1.6.1:runtime
[INFO] +- log4j:log4j:jar:1.2.16:compile
[INFO] +- org.eclipse.jetty:jetty-server:jar:7.6.13.v20130916:test
[INFO] |  +- org.eclipse.jetty.orbit:javax.servlet:jar:2.5.0.v201103041518:test
[INFO] |  +- org.eclipse.jetty:jetty-continuation:jar:7.6.13.v20130916:compile
[INFO] |  \- org.eclipse.jetty:jetty-http:jar:7.6.13.v20130916:compile
[INFO] +- org.apache.cxf:cxf-bundle-jaxrs:jar:2.7.7:compile
[INFO] |  +- org.codehaus.woodstox:woodstox-core-asl:jar:4.2.0:compile
[INFO] |  +- org.codehaus.woodstox:stax2-api:jar:3.1.1:compile
[INFO] |  +- org.apache.ws.xmlschema:xmlschema-core:jar:2.0.3:compile
[INFO] |  +- org.apache.geronimo.specs:geronimo-javamail_1.4_spec:jar:1.7.1:compile
[INFO] |  +- wsdl4j:wsdl4j:jar:1.6.3:compile
[INFO] |  +- org.eclipse.jetty:jetty-io:jar:8.1.12.v20130726:compile
[INFO] |  +- org.eclipse.jetty:jetty-util:jar:8.1.12.v20130726:compile
[INFO] |  +- org.eclipse.jetty:jetty-security:jar:8.1.12.v20130726:compile
[INFO] |  +- org.apache.geronimo.specs:geronimo-servlet_3.0_spec:jar:1.0:compile
[INFO] |  \- javax.ws.rs:javax.ws.rs-api:jar:2.0-m10:compile
[INFO] +- org.apache.cxf:cxf-api:jar:2.7.7:compile
[INFO] +- org.apache.cxf:cxf-rt-transports-http:jar:2.7.7:compile
[INFO] |  \- org.apache.cxf:cxf-rt-core:jar:2.7.7:compile
[INFO] +- org.apache.cxf:cxf-rt-ws-policy:jar:2.7.7:compile
[INFO] |  \- org.apache.neethi:neethi:jar:3.0.2:compile
[INFO] +- com.sun.xml.messaging.saaj:saaj-impl:jar:1.3.15:compile
[INFO] |  \- org.jvnet.mimepull:mimepull:jar:1.7:compile
[INFO] +- javax.xml.soap:saaj-api:jar:1.3.5:compile
[INFO] +- junit:junit:jar:4.8.2:test
[INFO] +- com.oracle:ojdbc6:jar:11.1.0.6.0:test
[INFO] \- org.springframework:spring-test:jar:3.0.5.RELEASE:test

1 个答案:

答案 0 :(得分:1)

我最后通过以下建议来解决这个问题:

https://issues.apache.org/jira/browse/CXF-4232http://salzotech.blogspot.com/2014/02/noclassdeffounderror.html

具体来说,我将其添加到Jersey ServletContextListener的开头:

@Override
public void contextInitialized(final ServletContextEvent sce) {
    //Fix this issue in WebLogic 12c:
    //http://salzotech.blogspot.com/2014/02/noclassdeffounderror.html
    RuntimeDelegate.setInstance(new com.sun.jersey.server.impl.provider.RuntimeDelegateImpl());

我不确定在此之后我是否必须做所有事情,但这是我做的其他事情:

将此添加到我的weblogic.xml:

<prefer-application-packages>
    <package-name>com.sun.jersey.*</package-name>
    <package-name>org.apache.*</package-name>
    <package-name>antlr.*</package-name>
    <package-name>javax.ws.rs.*</package-name>
</prefer-application-packages>

将此添加到我的pom文件中(使用了最新版本的Jersey。这个旧的CXF版本仍适用于我):

    <properties>
        <cxf-version>2.7.7</cxf-version>
        <com.sun.jersey.version>1.18.1</com.sun.jersey.version>
...
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-bundle-jaxrs</artifactId>
            <version>${cxf-version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-api</artifactId>
            <version>${cxf-version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>${cxf-version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-ws-policy</artifactId>
            <version>${cxf-version}</version>
        </dependency>