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

谁说我不能喝 提交于 2019-12-06 11:34:43

I ended up fixing this by following some suggestions from:

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

Specifically, I added this to the start of my 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());

I'm not sure if I had to do everything after this, but here are the other things I did:

Added this to my 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>

Added this to my pom file (used the latest version of Jersey. This older CXF version still worked for me):

    <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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!