Spring Boot Jersey Jboss RestEasy Issue RESTEASY003900

Spring Boot Jersey  JBoss RestEasy Issue:- 

I am working on one of my application and it has to be deployed on JBoss application server. Now we suddenly got this error in Jersey Jboss RestEasy Issue RESTEASY003900 .

As per my understanding, we think it is not a time-consuming Stuff. So I  have created a WAR of my Spring Boot app and deployed to JBoss. Once I deploy my war on   Spring Boot ,  Spring Boot Jersey JBoss RestEasy Issue started popping up. It Shows following error initially .

Cannot upload deployment: {"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host.\"/SpringBoot-Jersey-0.0.1-SNAPSHOT\"" => "java.lang.RuntimeException: java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer Caused by: java.lang.RuntimeException: java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer Caused by: java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer"}}

Looking into the error I realized there is a problem with WebSocket dependency of tomcat.We included following dependency in our project.

<dependency>

       <artifactId>tomcat-embed-websocket</artifactId>

       <groupId>org.apache.tomcat.embed</groupId>

      <scope>provided</scope>

</dependency>

Now I try to deploy in JBoss as a War file but got following error.

Cannot upload deployment: {"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host.\"/SpringBoot-Jersey-0.0.1-SNAPSHOT\"" => "java.lang.IllegalArgumentException: RESTEASY003900: Unable to find a public constructor for provider class com.frugalis.SpringBootJersey.JerseyConfig Caused by: java.lang.IllegalArgumentException: RESTEASY003900: Unable to find a public constructor for provider class com.frugalis.SpringBootJersey.JerseyConfig"}}

Now I am lost in a Black Hole. I googled and tried a lot of things. Hush !! Nothing Worked. Finally Got a Solution on JBoss forum.

Solution:-

As application server, Wildfly provides its own implementation of JAX-RS specification. Here the framework in play is RESTEasy, not Jersey.

The RESTEasy engine is trying to start Jersey’s feature and fail to do so. There is not so much unification in JAX-RS implementations so quite often they are incompatible.

You have two possible solutions

  1. Switch from Jersey to RESTEasy.
  2. Turn off Wildfly’s RESTEasy scanning of your application and start Jersey server internally.

I have Followed the second option, hence used,jboss-deployment-structure.xml where we are excluding RESTEasy module loading by jboss.We now create the file and put it in the folderWEB-INF of our application.It is a common problem in jersey related applications as both of the libraries uses the same annotation so we get a lot of issues.

<?xml version='1.0' encoding='UTF-8'?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
	<deployment>
		<exclude-subsystems>
			<subsystem name="resteasy" />
		</exclude-subsystems>
		<exclusions>
			<!-- <module name="javaee.api" />
			<module name="javax.ws.rs.api" /> -->
			<!-- <module name="org.jboss.resteasy.resteasy-jaxrs" /> -->
		</exclusions>
	</deployment>
</jboss-deployment-structure>

Attaching my source code, hope it helps a lot of guys like me. Share With me if you find any issues or face any issues.I will be happy to help you. Comment on my posts or email me for any issues on Spring Boot ,Java,J2EE or programming language on which i do blogging .Lets Share and Learn .

Download Code