NoClassDefFoundError ProcessingException while migrating from jersey 1.x to jersey 2.x ( 2.8 )

后端 未结 2 1887
长发绾君心
长发绾君心 2021-01-19 04:31

I developed a web service application which was working fine with jersey 1.x ( 1.16 ) I recently tried to migrate to latest stable jersey version 2.8

I deleted all j

相关标签:
2条回答
  • 2021-01-19 05:09

    If you are working in eclipse. Just remove the libraries from Deployment Assembly and add them again. Sometimes after adding new jar does not update the library of the web application

    BuildPath->Deployment Assembly

    0 讨论(0)
  • 2021-01-19 05:15

    Exception you are getting is happening because you downloaded "javax.ws.rs-api-2.0-m09.jar" this jar doesn't have ProcessingException download the latest one

    Class not foundCaused by: java.lang.NoClassDefFoundError: javax/ws/rs/ProcessingException
    

    Download this jar javax.ws.rs-api-2.0.jar

    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>javax.ws.rs-api</artifactId>
        <version>2.0</version>
    </dependency>
    

    Secondly I think you are missing a part from your web.xml

    Try adding these things to your web.xml as appropriate for you application. If you don't have this section this may also lead to SEVERE: A child container failed during start....

    This is what you are missing. Please note that param-value is the list of packages that contain your rest services.

    <servlet>
        <servlet-name>jersey-serlvet</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>jersey.config.server.provider.packages;org.codehaus.jackson.jaxrs</param-name>
            <param-value>com.your.package.for.rest</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    

    To get latest Jackson use this Link

    <dependency>
        <groupId>com.fasterxml.jackson.jaxrs</groupId>
        <artifactId>jackson-jaxrs-json-provider</artifactId>
        <version>2.3.3</version>
    </dependency>
    
    0 讨论(0)
提交回复
热议问题