CXF ClassNotFoundException: javax.ws.rs.MessageProcessingException
Solution 1
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>
Solution 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.
Solution 3
I had the same issue & I had to add this exclusion -
<exclusion>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
</exclusion>
Solution 4
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.
Related videos on Youtube
Crushing
Updated on June 04, 2022Comments
-
Crushing about 2 years
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>
-
Paul Samsotha over 9 yearsShow your dependencies. Check if you have jsr311 on the classpath.
-
Paul Samsotha over 9 yearsI did not say to add jsr311, I said to check if you have it. The two jax-rs versions are not compatible
-
Paul Samsotha over 9 yearsIf you take out both explicit jax-rs dependencies, do you still have the problem. cxf already has its own dependency
-
Paul Samsotha over 9 yearsAs 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.x -
honestduane about 9 yearsWhat is your full POM? I'm running into this issue myself at the moment and I notice that hat you posted seems incomplete.
-