0 Replies Latest reply on Mar 13, 2012 4:57 AM by Luca Merolla

    Classloading and JAX-RS problem with AS7.1.1

    Luca Merolla Newbie

      Hello everyone,

       

      I have opened a new thread on a problem that I was facing with RESTeasy because the problem seems different than the original post https://community.jboss.org/message/723187

       

      In the structure of my project I have 2 libraries: test-common.jar and test-remote.jar. common needs the remote library, so it depends on it.

      These 2 libraries are used by all the WARs and EJB (jar) which are deployed inside my EAR. In order to deploy my application correctly, I have deployed the 2 libraries under the modules folder of Jboss and under EAR/lib folder.

      Then I have a WAR application test-portone.war, which is a RESTfull application and is deployed inside my open EAR.

       

      Everything seems to work, excepts some REST calls. In particular, the REST call like this:

      @POST

      @Path("action/bet")

      @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })

      @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })

      ResponseDTO sendBettingAction(@Context SecurityContext sec, BettingTicket ticket);

       

      @GET

      @Path("test")

      @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })

      BettingTicket testReturnAction(@Context SecurityContext sec);

       

      the problem is BettingTicket class. This class is stored inside the test-remote library and it is annotated as follow

      @XmlRootElement(name = "betting-ticket")

      @XmlAccessorType(XmlAccessType.FIELD)

      @XmlType(propOrder = { "command", "idGametable", "idPlayer", "betValue", "type" })

      public class BettingTicket extends AbstractBettingTicket {

       

         private static final long serialVersionUID = 6907760191262653485L;

       

         public BettingTicket() {

        // TODO Auto-generated constructor stub

         }

      }

       

      @XmlTransient

      public abstract class AbstractBettingTicket implements Serializable {

       

         private static final long serialVersionUID = 6907760191262653485L;

       

         @XmlElement

         protected BettingCommand command;

         @XmlElement

         protected long idGametable;

         @XmlElement

         protected long idPlayer;

         @XmlElement

         protected BigDecimal betValue;

         @XmlElement

         protected GametableType type;

       

      // getters and setters...

      }

       

      I have been trying to change the structure of BettingTicket but it seems that is not the problem. In fact, the problem seems to be that BettingTicket can't be marshalled/unmarshalled to xml/java for some reasons, and I guess it's because annotations doesn't get recognized.

       

      Here is the structure of my deployment:

      -module

      -----test-common.jar

      -----test-remote.jar (contains the BettingTicket.java)

      -standalone/deployments

      -----myEAR

      ---------test-ejb.jar

      ---------test-portone.war (it's my REST application)

      ---------other war...

      -----myEAR/lib

      ---------test-common.jar

      ---------test-remote.jar

       

      Here is the error when performing the POST

      11:24:26,862 SEVERE [org.jboss.resteasy.core.SynchronousDispatcher] (http-localhost.localdomain-127.0.0.1-8080-1) Failed executing POST /clientgame/action/bet: org.jboss.resteasy.spi.BadRequestException: Could not find message body reader for type: class org.test.remote.testgame.tickets.BettingTicket of content type: application/xml;charset="UTF-8"

                at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:153) [resteasy-jaxrs-2.3.2.Final.jar:]

                at org.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:124) [resteasy-jaxrs-2.3.2.Final.jar:]

                at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:147) [resteasy-jaxrs-2.3.2.Final.jar:]

                at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257) [resteasy-jaxrs-2.3.2.Final.jar:]

                at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:222) [resteasy-jaxrs-2.3.2.Final.jar:]

                at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:211) [resteasy-jaxrs-2.3.2.Final.jar:]

                at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:525) [resteasy-jaxrs-2.3.2.Final.jar:]

                at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:502) [resteasy-jaxrs-2.3.2.Final.jar:]

                at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119) [resteasy-jaxrs-2.3.2.Final.jar:]

                at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.3.2.Final.jar:]

                at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.3.2.Final.jar:]

                at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.3.2.Final.jar:]

                at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

                at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:489) [jbossweb-7.0.13.Final.jar:]

                at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]

                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]

                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]

                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]

                at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_26]

       

      And here is the error when I perform the GET

      09:40:54,301 SEVERE [org.jboss.resteasy.core.SynchronousDispatcher] (http-localhost.localdomain-127.0.0.1-8080-1) Failed executing GET /clientgame/test: org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: org.test.remote.testgame.tickets.BettingTicket of media type: application/xml

        at org.jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.java:216) [resteasy-jaxrs-2.3.2.Final.jar:]

        at org.jboss.resteasy.core.SynchronousDispatcher.writeJaxrsResponse(SynchronousDispatcher.java:585) [resteasy-jaxrs-2.3.2.Final.jar:]

        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:506) [resteasy-jaxrs-2.3.2.Final.jar:]

        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119) [resteasy-jaxrs-2.3.2.Final.jar:]

        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.3.2.Final.jar:]

        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.3.2.Final.jar:]

        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.3.2.Final.jar:]

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

        at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]

        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]

        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]

        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:489) [jbossweb-7.0.13.Final.jar:]

        at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

        at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]

        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]

        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]

        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]

        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]

        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]

        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]

        at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_26]

       

      Another test that I have been running was to copy the BettingTicket class from the test-remote library to the WAR of the REST application and this showed to fix the issue.

      However, this approach is not possible to me because these classes needs to be in the remote library because they are used by remote clients in order to exchange information with the server with REST calls, so I need to understand how can I fix this problem because it seems related to the classloading of that BettingTicket.

      Maybe the BettingTicket annotations are not processed correctly if it is inside the test-remote.jar library and loaded as module?

       

      Thanks in advance,

      LM