6 Replies Latest reply on Nov 19, 2011 8:02 AM by maxsap

    RestEasy Deployment problem

    maxsap

      Hello all, I dont really know if this is the correct plase to post this, but since I was not allowed to post to the RestEasy forum this is the closest I could.

      I am new to REstEasy and I much confused about the configurations needed and how to get started.

      I have a Jersey project that I would like to port to RestEasy, after some reading I managed to create the web.xml and get some results (Using AS7 in localhost).

      When I tried to deploy the example in a remote server (used the eclipse and when that faild simply copied the .war file to the server) I was got this:

       

      15:15:40,761 INFO  [org.jboss.weld] (MSC service thread 1-2) Starting weld service
      15:15:40,908 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-4) Context [/feelzer] startup failed due to previous errors: java.lang.IllegalArgumentException: Duplicate context initialization parameter resteasy.injector.factory
                at org.apache.catalina.core.StandardContext.addParameter(StandardContext.java:2162) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
                at org.jboss.as.web.deployment.JBossContextConfig.processWebMetaData(JBossContextConfig.java:294) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]
                at org.jboss.as.web.deployment.JBossContextConfig.applicationWebConfig(JBossContextConfig.java:167) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]
                at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:417) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
                at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:182) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
                at org.jboss.as.web.deployment.JBossContextConfig.lifecycleEvent(JBossContextConfig.java:160) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]
                at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:115) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
                at org.apache.catalina.core.StandardContext.start(StandardContext.java:3766) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
                at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]
                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824)
                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [:1.7.0_01]
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.7.0_01]
                at java.lang.Thread.run(Thread.java:722) [:1.7.0_01]
      
      
      15:15:40,910 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-4) Context [/feelzer] startup failed due to previous errors
      
      

       

      Since then I searched the web in order to find more info and found this: http://www.mastertheboss.com/web-interfaces/273-resteasy-tutorial-.html

      If I understand correctly RestEasy comes bundled with AS, with that in mind, to create a new rest application we only need to add

      <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                                         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
      </web-app> 
      
      
      

      in our Web.xml file and the rest are handled by the AS it self, no need to specify the ResteasyBootstrap listener and the HttpServletDispatcher servlet and only need the POJO with the correct annotations that will be peekedup bu the server correct?

      When I tried that I keeped getting 404 errors.

      Also please note that even thought I have changed the Web.xml and placed the above mentioned in the xml file, the 404 continued.

      My POJO is named HelloWorld and the project is named RestEasy (Taken from the link provided above in order to use the correct path).

      Also I have tried to remove the jar files from the projects lib folder because I have read that the server already bundles them and thought that this could be the root of the problem.

      So I have three questions:

      1. Why I can deploy the example locally and get it to work and when I try to deploy on a remote server with the same configurations I am getting that error?
      2. What are the needed configurations to get the RestEasy on a project, (do I need the servlet mapping, Do I have to add the external jars or those comes bundled e.t.c.)
      3. And finnaly why even though I managed to deploy the example from that site I kept on getting 404 errors?

      Thanks in advanced and sorry for the length of my question but I think those questions will help a lot newcomers as my self, best regards maxsap.

        • 1. Re: RestEasy Deployment problem
          jaikiran
          • 2. Re: RestEasy Deployment problem
            maxsap

            Hello jaijiran,

            Thank you for your responce,correct me if I am mistaken but in the RestEasy reference guide in chapter "3.6. Install/Config in JBoss 6-M4 and Higher" specifically says:

             

            RESTEasy is preconfigured and completely integrated with JBoss 6-M4 and higher. You can use

            it with EJB and CDI and you can rely completely on JBoss for scanning for your JAX-RS services

            and deploying them. All you have to provide is your JAX-RS service classes packaged within a

            WAR either as POJOs, CDI beans, or EJBs and provide an empty web.xml file as follows:

             

            <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"

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

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

            </web-app>

             

            And in the link you have provided I see different suggestions, wich is the correct because I am a little bit confused.

            Also I have managed to deploy my app using the second method suggested by your URL "Subclassing javax.ws.rs.core.Application and using web.xml". The project was successfully deployed in both the remote and the local server and worked great, until I made some changes and from that point on I am getting this error again:

             

            23:40:13,130 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-3) Context [/RestEasy] startup failed due to previous errors: java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name javax.ws.rs.core.Application

                      at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:2231) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                      at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:2210) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                      at org.jboss.as.web.deployment.JBossContextConfig.processWebMetaData(JBossContextConfig.java:482) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]

                      at org.jboss.as.web.deployment.JBossContextConfig.applicationWebConfig(JBossContextConfig.java:167) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]

                      at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:417) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                      at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:182) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                      at org.jboss.as.web.deployment.JBossContextConfig.lifecycleEvent(JBossContextConfig.java:160) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]

                      at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:115) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                      at org.apache.catalina.core.StandardContext.start(StandardContext.java:3766) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                      at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]

                      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824)

                      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759)

                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [:1.7.0]

                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.7.0]

                      at java.lang.Thread.run(Thread.java:722) [:1.7.0]

             

            Note I have erased all the changes done and brought the project to the state when it was deploying succesffully but the error insisted!

            Could this be a bug or a configuration error?

            Is this a server specific error or resteasy is causing it?

            is the possibility of missing jar files in the build path causing it?

            P.S. If I provide JBoss with an emtpy web.xml file as described in the reference, I dont get any deployment errors but I am getting 404 errors.

            Best regards maxsap.

            • 3. Re: RestEasy Deployment problem
              maxsap

              Anyone any suggestion? this should have worked out of the box ass the documentation discribes!

              • 4. Re: RestEasy Deployment problem
                beve

                Hi,

                 

                Can you post your web.xml?

                 

                Regards,

                 

                /Daniel

                • 5. Re: RestEasy Deployment problem
                  j4m3s

                  Have you implemented a REST service in your class/ package?  using the @Path("/hello") annotation or similar?  I just got this error and realised that it's because I removed the annotation on my class by accident - so i guess jboss was telling me that it didn't know what to do with this mapping as it had nowhere that actually implemented it.

                   

                  Just a thought.

                   

                  James.

                  • 6. Re: RestEasy Deployment problem
                    maxsap

                    Hello all, I am using an empty xml file nothing as suggested by the jboss docs. I have found the problem from here: http://stackoverflow.com/questions/611465/tomcat-is-unable-to-find-my-servlet-and-is-throwing-exceptions-but-why

                    The problem is that I was using wrong jdk.

                    Sorry for the late responce.