泽西岛的NoClassDefFoundError

时间:2015-10-21 18:13:18

标签: java jersey jax-rs

由于下面的NoClassDefFoundError错误,我的应用程序返回500错误。我使用的是Weblogic 12.1.2,其中包括Jersey。

我的pom文件:

   <properties>
        <com.sun.jersey.version>1.17.1</com.sun.jersey.version>
...
            <dependency>
                <groupId>org.atmosphere</groupId>
                <artifactId>atmosphere-jersey</artifactId>
                <version>0.7.2</version>
                <type>jar</type>
            </dependency>
           <dependency>
                <groupId>com.sun.jersey</groupId>
                <artifactId>jersey-server</artifactId>
                <version>${com.sun.jersey.version}</version>
                <type>jar</type>
            </dependency>
            <dependency>
                <groupId>com.sun.jersey</groupId>
                <artifactId>jersey-client</artifactId>
                <version>${com.sun.jersey.version}</version>
                <type>jar</type>
            </dependency>
            <dependency>
                <groupId>com.sun.jersey.contribs</groupId>
                <artifactId>jersey-atom-abdera</artifactId>
                <version>${com.sun.jersey.version}</version>
                <type>jar</type>
            </dependency>
            <dependency>
                <groupId>com.sun.jersey</groupId>
                <artifactId>jersey-atom</artifactId>
                <version>${com.sun.jersey.version}</version>
                <type>jar</type>
            </dependency>
            <dependency>
                <groupId>com.sun.jersey</groupId>
                <artifactId>jersey-json</artifactId>
                <version>${com.sun.jersey.version}</version>
                <type>jar</type>
            </dependency>
            <dependency>
                <groupId>com.sun.jersey.contribs</groupId>
                <artifactId>jersey-multipart</artifactId>
                <version>${com.sun.jersey.version}</version>
                <type>jar</type>
            </dependency>
            <dependency>
                <groupId>com.sun.jersey.contribs</groupId>
                <artifactId>jersey-spring</artifactId>
                <version>${com.sun.jersey.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-core</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>com.sun.jersey.contribs</groupId>
                <artifactId>jersey-guice</artifactId>
                <version>${com.sun.jersey.version}</version>
                <type>jar</type>
            </dependency>


]] Root cause of ServletException.
java.lang.NoClassDefFoundError: com/sun/jersey/core/impl/provider/header/WriterUtil
        at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.toString(MediaTypeProvider.java:66)
        at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.toString(MediaTypeProvider.java:53)
        at com.sun.jersey.spi.container.ContainerResponse.getHeaderValue(ContainerResponse.java:213)
        at com.sun.jersey.spi.container.servlet.WebComponent$Writer.writeHeaders(WebComponent.java:347)
        at com.sun.jersey.spi.container.servlet.WebComponent$Writer.writeStatusAndHeaders(WebComponent.java:335)
        Truncated. see log file for 

完成堆栈跟踪

]] Root cause of ServletException.
java.lang.NoClassDefFoundError: com/sun/jersey/core/impl/provider/header/WriterUtil
        at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.toString(MediaTypeProvider.java:66)
        at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.toString(MediaTypeProvider.java:53)
        at com.sun.jersey.spi.container.ContainerResponse.getHeaderValue(ContainerResponse.java:213)
        at com.sun.jersey.spi.container.servlet.WebComponent$Writer.writeHeaders(WebComponent.java:347)
        at com.sun.jersey.spi.container.servlet.WebComponent$Writer.writeStatusAndHeaders(WebComponent.java:335)
        Truncated. see log file for complete stacktrace

1 个答案:

答案 0 :(得分:2)

如果要使用Weblogic提供的库,则依赖项应标记​​为

<scope>provided</scope>

否则,您将引入外部依赖关系并使用这些依赖部署您的应用程序...换句话说,您正在使用外部依赖项编译和打包您的应用程序,而不是Weblogic为运行时提供的库