CXF ClassNotFoundException: javax.ws.rs.MessageProcessingException
Asked Answered
S

4

5

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>
Suburbanize answered 14/3, 2015 at 22:2 Comment(5)
Show your dependencies. Check if you have jsr311 on the classpath.Winded
I did not say to add jsr311, I said to check if you have it. The two jax-rs versions are not compatibleWinded
If you take out both explicit jax-rs dependencies, do you still have the problem. cxf already has its own dependencyWinded
As an aside, if you are looking for full jax-rs 2 compatibility, 2.7.0 won't offer that. jax-rs 2 doesn't have the MessageProcessingException. You can go through the cxf dependent milestone jar, and it is there, but if you do through the 2.0 jar, you currently have as a depedency, it's not there. For full jax-rs 2 compatibility, look into using cxf 3.x.xWinded
What is your full POM? I'm running into this issue myself at the moment and I notice that hat you posted seems incomplete.Shutt
D
3

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>
Depilatory answered 17/12, 2016 at 13:48 Comment(0)
D
2
<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.

Delatorre answered 21/7, 2015 at 16:6 Comment(0)
M
1

I took this same error using Jersey client without JSON/JAXB providers to do the calls to server, when I configure Jettison provider the problem was solved. This erros also occour when I use a incompatible POJO to marshaling object to call service. check it. I hope this help.

The problem also occur when you have Classloader problems, check your maven dependecy hierarchy conflicts of jax-rs. In my case I need to use exlcusion filter in my pom.xml like

<exclusions>
    <exclusion>
        <artifactId>javax.ws.rs-api</artifactId>
        <groupId>javax.ws.rs</groupId>
    </exclusion>
</exclusions>

I made exclusion in cxf-bundle-jaxrs in another project that uses javax.ws.rs-api dependency. Using dependency of cxf-rt-frontend-jaxrs:2.7.11 was sufficient.

Melena answered 10/4, 2015 at 21:55 Comment(0)
B
1

I had the same issue & I had to add this exclusion -

            <exclusion>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-frontend-jaxrs</artifactId>
            </exclusion>
Beckiebeckley answered 27/7, 2016 at 17:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.