简体   繁体   中英

NoClassDefFoundError in Jersey

My application is returning a 500 error due to the NoClassDefFoundError error below. I'm using Weblogic 12.1.2, which includes Jersey.

My pom file:

   <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 

complete stacktrace

]] 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

If you want to use the libraries provided by Weblogic then the dependencies should be marked as

<scope>provided</scope>

otherwise you'll be pulling in external dependencies and deploying your app with these... in other words, you're compiling against and packaging your app with external dependencies, not the libraries provided by Weblogic for runtime.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM