Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CXF ClassNotFoundException: javax.ws.rs.MessageProcessingException

I'm trying to start a jax ws & rs server endpoints, I can get them started using rs-api 2.0 (and version 2.0.1) but when I try to make a request it throws

java.lang.NoClassDefFoundError: javax/ws/rs/MessageProcessingException  

There are some other threads in SO regarding this matter but the suggestions don't work for me. Using any of the rs-api 2 milestone versions throws issues

Exception in thread "main" java.lang.NoClassDefFoundError: javax/ws/rs/BadRequestException

I'm running this as a java application, not a webapp. Anyone have any ideas to try? Thanks

EDIT: My dependencies. I added jsr311 but that did not change the MessageProcessingException

 <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-c3p0</artifactId>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
    </dependency>
    <dependency>
        <groupId>postgresql</groupId>
        <artifactId>postgresql</artifactId>
    </dependency>

    CXF: version 2.7.0
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxrs</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http-jetty</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-ws-security</artifactId>
    </dependency>

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

    jsr311 version: 1.1.1
    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>jsr311-api</artifactId>
    </dependency>
like image 329
Crushing Avatar asked Mar 14 '15 22:03

Crushing


2 Answers

Faced the same issue, but later when I used 3.0.0-milestone2 of cxf-bundle with 2.1-m01 of javax.ws.rs-api, it worked like a charm.

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

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-bundle</artifactId>
    <version>3.0.0-milestone2</version>
</dependency>
like image 74
Ankit Bhatia Avatar answered Oct 28 '22 07:10

Ankit Bhatia


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

This version has support for javax.ws.rs.MessageProcessingException class.

like image 44
k k Avatar answered Oct 28 '22 07:10

k k