10 Replies Latest reply on Sep 29, 2015 12:17 PM by javigs82

    Resteasy 3 application not working on JBoss AS 7.1.1 - Gives HTTP 404 with no log message

    tadhg.pearson

      I've developed a RESTful webservice using RestEasy 3.0.6 and it's Jackson 2 plugin. It works great in Jetty! But we use JBoss AS 7.1.1 AS in production and when I deploy it to JBoss, I get an 404 when I hit the APIs server URL, and no info in the logs.

       

      I assumed that this was because of the built-in version of RestEasy 2.3.2 that ships with JBoss taking precedence over my WAR-provided version, so I created a jboss-deployment-structure.xml to exclude the subsystem like it says in the manual at Class Loading in AS7 - JBoss AS 7.0 - Project Documentation Editor

      When that gave me an error parsing the XML (because it's not actually supported - see the comments in that manual entry) I tried manually excluding the modules. But this just brought me back in a loop, and now I have no errors again. It's like the exclusion is not working - or my problem was not to do with the exclusion in the first place.

       

      When I deploy me application now, I do get the following warnings. I can't understand why

      16:17:37,781 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-16) Class Path entry jaxb-api.jar in "/G:/java/jboss-as-7.1.1.Final/bin/content/my.war/WEB-INF/lib/jaxb-core-2.2.7.jar"  does not point to a valid jar for a Class-Path reference.
      16:17:37,784 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-16) Class Path entry jaxb-api.jar in "/G:/java/jboss-as-7.1.1.Final/bin/content/my.war/WEB-INF/lib/jaxb-impl-2.2.7.jar"  does not point to a valid jar for a Class-Path reference.
      16:17:37,789 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-16) Class Path entry jaxb-core.jar in "/G:/java/jboss-as-7.1.1.Final/bin/content/my.war/WEB-INF/lib/jaxb-impl-2.2.7.jar"  does not point to a valid jar for a Class-Path reference.
      
      

       

      My web.xml looks like this

      <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
          version="2.4">
      
          <display-name>My App</display-name>
      
          <servlet>
              <servlet-name>my</servlet-name>
              <servlet-class>
                  org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
              <init-param>
                  <param-name>javax.ws.rs.Application</param-name>
                  <param-value>my.fqn.WebApp</param-value>
              </init-param>
          </servlet>
      
          <servlet-mapping>
              <servlet-name>api</servlet-name>
              <url-pattern>/api/*</url-pattern>
          </servlet-mapping>
      
          <context-param>
              <param-name>resteasy.providers</param-name>
              <param-value>my.fqn.conf.JSONProvider, my.fqn.conf.conf.ValidationExceptionMapper</param-value>
          </context-param>
      
      </web-app>
      
      

       

      and my jboss-deployment-structure.xml looks like this

      <jboss-deployment-structure>
          <deployment>
              <exclusions>
                  <module name="org.jboss.resteasy.resteasy-atom-provider" />
                  <module name="org.jboss.resteasy.resteasy-cdi" />
                  <module name="org.jboss.resteasy.resteasy-jaxrs" />
                  <module name="org.jboss.resteasy.resteasy-jaxb-provider" />
                  <module name="org.jboss.resteasy.resteasy-jackson-provider" />
                  <module name="org.jboss.resteasy.resteasy-jsapi" />
                  <module name="org.jboss.resteasy.resteasy-multipart-provider" />
                  <module name="org.jboss.resteasy.async-http-servlet-30" />
              </exclusions>
          </deployment>
      </jboss-deployment-structure>
      
      

       

      Unfortunately, using another version of JBoss AS is not an option.

      Any ideas about what I'm missing here would be greatly appreciated.

       

      Thanks, Tadhg

        • 1. Re: Resteasy 3 application not working on JBoss AS 7.1.1 - Gives HTTP 404 with no log message
          tadhg.pearson

          Huh. Well, after debugging my way though the RestEasy source (which reads like a good novel, nice work guys!) I realized that for some reason the @Path annotation for my resource class was being ignored.

           

          When I moved from Jetty to Tomcat I had to slightly rearrange my sources, and because of the way I did it, maven started importing an older JAR without the @Path annotation on the resource class. No @Path means no URL.

           

          What was confusing was that the class registration still appeared in the logs because it was being imported in the getSingletons method, but it wasn't registering any paths. It would be useful for developers if RestEasy warned when you add a class with no paths as a singleton.

          • 2. Re: Re: Resteasy 3 application not working on JBoss AS 7.1.1 - Gives HTTP 404 with no log message
            tadhg.pearson

            Humm... now I'm stuck again though.

             

            I'm getting the exception

            17:28:19,909 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/travel-innovation-sandbox].[sandbox]]

            (http--127.0.0.1-8080-1) Servlet.service() for servlet sandbox threw exception:

            java.lang.NoSuchMethodError: org.jboss.resteasy.specimpl.BuiltResponse.getHeaders()Ljavax/ws/rs/core/MultivaluedMap;

             

            Clearly it's an issue with my jboss-deployment-structure.xml in this case because when I manually overwrite my built-in Resteasy with the v3.0.6 based on the instructions at http://docs.jboss.org/resteasy/docs/3.0.6.Final/userguide/html_single/index.html#upgrading-as7 it magically works!

             

            Any ideas how I can customize my jboss-deployment-structure.xml to work correctly?!

            • 3. Re: Re: Resteasy 3 application not working on JBoss AS 7.1.1 - Gives HTTP 404 with no log message
              vbchin2

              The NoSuchMethodError is suggesting that you are using one set of libraries in development and another in runtime. Since you overwrote the module libraries:

              1. Open the module folder and note the JARs for their version.
              2. Once done, reference the same set of JARs via Maven and mark them provided so that your WAR/EAR doesn't package those JARs along with rest of your classfiles.
              3. Now try initially with no jboss-deployment-structure.xml file. If in runtime you see ClassNotFoundException errors then declare a dependency on the REST module either via .xml file or via the MANIFEST.MF file.

              Hope I made some sense and you are able to resolve the issue ...

              • 4. Re: Re: Resteasy 3 application not working on JBoss AS 7.1.1 - Gives HTTP 404 with no log message
                tadhg.pearson

                Hi Vijay,

                 

                Thanks for the response but it doesn't really resolve the issue.

                The standard version of JBoss 7 AS is shipping with Resteasy 2.something.

                My WAR is packaging Resteasy 3.0.6

                 

                Whether I declare my dependency on 3.0.6 as provided (so it's not included in the WAR) or not provided (so it ships in the WAR) has the same effect - JBoss uses the version of RestEasy in it's own modules folder - not the one against which I compiled.

                 

                This is then demonstrated by the fact that if I upgrade the version in my modules folder on my local machine to 3.0.6, it suddenly starts working (again, regardless of whether I mark the dependency as provided or not in Maven). But I won't have this option in my production environment.

                 

                Therefore, I have to exclude the module version of Resteasy from being used by JBoss. Clearly the jboss-deployment-structure.xml above isn't working - have you any suggestions of how I could modify it to correctly exclude the built-in Resteasy 2 module?

                • 5. Re: Resteasy 3 application not working on JBoss AS 7.1.1 - Gives HTTP 404 with no log message
                  vbchin2

                  I suspect that the jboss-deployment-structure.xml (duh! perhaps) isn't being properly processed. Can you confirm where it is located in the WAR ? Based on the documentation below it should be in the WEB-INF.

                   

                  If it is in the right place, one weird way to confirm it is being processed is to have a file content that wouldn't pass XML validation (miss a tag or something) and verify if JBoss catches it.

                   

                  Class Loading in AS7 - JBoss AS 7.1 - Project Documentation Editor

                  • 6. Re: Re: Resteasy 3 application not working on JBoss AS 7.1.1 - Gives HTTP 404 with no log message
                    tadhg.pearson

                    Yup, that's right

                    WEB-INF\jboss-deployment-structure.xml

                     

                    I know it's being parsed because when I do

                     

                    <jboss-deployment-structure>

                        <deployment>

                            <exclusions>

                                <exclude-subsystems>

                                    <subsystem name="resteasy" />

                                </exclude-subsystems>

                            </exclusions>

                        </deployment>

                    </jboss-deployment-structure>

                    I get a schema exception

                     

                    13:37:16,207 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC00001: Failed to start service jboss.deploym

                    ent.unit."travel-innovation-sandbox.war".STRUCTURE: org.jboss.msc.service.StartException in service jboss.deployment.uni

                    t."travel-innovation-sandbox.war".STRUCTURE: Failed to process phase STRUCTURE of deployment "travel-innovation-sandbox.

                    war"

                    ...

                    Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[4,4]

                    Message: Unexpected content of type 'element start' named 'exclude-subsystems'

                    • 7. Re: Resteasy 3 application not working on JBoss AS 7.1.1 - Gives HTTP 404 with no log message
                      vbchin2

                      Okay! since I am running out of ideas, the last offer of help I would like to make is: If you could package up a simple webapp app without any business/company logic in it and it fails to deploy for absolutely the same reasons then I am more than willing to test it out in my environment and provide the solution if/when I arrive at it. If you could do that, that would be great!

                      • 8. Re: Resteasy 3 application not working on JBoss AS 7.1.1 - Gives HTTP 404 with no log message
                        tadhg.pearson

                        Wow Vijay - that's very kind of you - thanks!

                         

                        You can check out the project here which exhibits the same issue >> https://github.com/tadhgpearson/jboss-resteasy-test

                         

                        I added two more exclusions as I went though, I realized that I also needed to exclude the logging subsystem, but that didn't fix it.

                         

                        I also found this article, which is not promising! http://java.dzone.com/articles/jboss-modules-suck-it%E2%80%99s

                        • 9. Re: Re: Resteasy 3 application not working on JBoss AS 7.1.1 - Gives HTTP 404 with no log message
                          vbchin2

                          I have some news for you and it isn't good. The culprit seems to be the module: javax.ws.rs.api. Regardless of whether you

                          • Remove the jaxrs and webservices or extensions from the standalone.xml file
                          • Exclude module dependencies thru the jboss-deployment-structure.xml file in your WAR file

                          if the JBoss server realizes that you are accessing a RESTful webservices then it routes your request thru the module mentioned above. And that module, to put it mildly, is causing all the problem. Unfortunately I cannot go into specifics as honestly I myself do not know how the routing works, but if you replace this module with the new set the document suggest (just this module), things start to work.

                           

                          So in summary, you cannot do much if the JBoss server modules cannot be updated.

                           

                          I have done various tests and I list them below for you to know. None of the approached listed below worked in fixing the underlying issue:

                          1. Removed extensions org.jboss.as.webservices and org.jboss.as.jaxrs from the top portion of the standalone*.xml
                          2. Removed the subsystems <subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/> and <subsystem xmlns="urn:jboss:domain:webservices:1.1">. There is no way to do this subsystem exclusion via the jboss-deployment-structure.xml file for AS 7.1.1. The support for it was provided in versions 7.1.2.
                          3. Removed he culprit module folder (javax.ws.rs.api) to see if the module is skipped. The bootup doesn't complain about its existence but once you deploy the WAR the lack of this module is then noted.
                          4. The last thing I tried it to have a clean copy of AS 7.1.1 installation but replace the culprit module jars with new ones. Now the jboss-deployment-structure.xml gets picked up and the new jars you package with your WAR get processed.

                           

                          Sorry, I wish I had a solution you much desired.

                          • 10. Re: Resteasy 3 application not working on JBoss AS 7.1.1 - Gives HTTP 404 with no log message
                            javigs82

                            Following environment works in JBoss as 7.1

                            RestEasy3.0.11.Final + JAVAX-RS2 + Servlet 3 + EJB 3.1 + JPA + Hibernate --> EAR: war + 2ejbModules + N jars

                             

                            In my case, it is not necessasry to configure/exclude any Jboss Modules, just adding  Maven Dependecies into my EAR application.

                             

                            Configuration via web.xml because via annotations I always got HTTP 404.

                             

                            -->web.xml

                            <?xml version="1.0" encoding="UTF-8"?>

                            <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                              xmlns="http://java.sun.com/xml/ns/javaee"

                              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"

                              id="api" version="3.0">

                              <display-name>api</display-name>

                              <filter>

                              <filter-name>http-headers-filter</filter-name>

                              <filter-class>com.ef2f.api.filter.common.HttpHeadersFilter</filter-class>

                              </filter>

                              <filter-mapping>

                              <filter-name>http-headers-filter</filter-name>

                              <url-pattern>/rest/*</url-pattern>

                              </filter-mapping>

                              <context-param>

                              <param-name>resteasy.jndi.resources</param-name>

                              <param-value>

                              java:module/DumpResource

                              </param-value>

                              </context-param>

                             

                              <context-param>

                                  <param-name>resteasy.servlet.mapping.prefix</param-name>

                                  <param-value>/rest</param-value>

                               </context-param>

                             

                              <listener>

                              <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>

                              </listener>

                             

                              <servlet>

                              <servlet-name>Resteasy</servlet-name>

                              <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>

                              </servlet>

                             

                              <servlet-mapping>

                              <servlet-name>Resteasy</servlet-name>

                              <url-pattern>/rest/*</url-pattern>

                              </servlet-mapping>

                            </web-app>

                             

                            I hope this info can help people but this forum is a bit old.