3 Replies Latest reply on Aug 29, 2009 1:23 PM by Juergen Zimmermann

    RESTful WS with Jersey problem on Jboss only.. ?

    Bruno Lopes Newbie

      Hi,

      I have this situation, using jersey with restful webservices.
      My web.xml has among others things these lines:
      ...

      <context-param>
      <param-name>org.restlet.application</param-name>
      <param-value>
      com.movensis.cisl.ncarUsers.presentation.rrh.FirstStepsApplication
      </param-value>
      </context-param>


      <servlet-name>JerseyAPI</servlet-name>

      com.sun.jersey.spi.container.servlet.ServletContainer
      </servlet-class>
      <init-param>
      <param-name>
      com.sun.jersey.config.property.packages</param-name>

      com.movensis.cisl.ncarUsers.presentation.rrh
      </param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>

      ...

      During deploying the exception is:

      18:38:07,720 INFO [TomcatDeployment] undeploy, ctxPath=/jersey
      18:38:07,724 INFO [[/jersey]] Closing Spring root WebApplicationContext
      18:38:07,725 INFO [XmlWebApplicationContext] Closing org.springframework.web.context.support.XmlWebApplicationContext@162eb9a: display name
      [Root WebApplicationContext]; startup date [Fri Aug 21 18:36:53 BST 2009]; root of context hierarchy
      18:38:07,728 INFO [DefaultListableBeanFactory] Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactor
      y@12a2956: defining beans [org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.config.internalTransactio
      nAdvisor,dataSource,transactionManager,userManager,labManager,divisionManager,userDao,labDao,divisionDao]; root of factory hierarchy
      18:38:17,534 INFO [TomcatDeployment] deploy, ctxPath=/jersey
      18:38:17,766 INFO [[/jersey]] Initializing Spring root WebApplicationContext
      18:38:17,767 INFO [ContextLoader] Root WebApplicationContext: initialization started
      18:38:17,807 INFO [XmlWebApplicationContext] Refreshing org.springframework.web.context.support.XmlWebApplicationContext@45325f: display na
      me [Root WebApplicationContext]; startup date [Fri Aug 21 18:38:17 BST 2009]; root of context hierarchy
      18:38:17,880 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from class path resource [applicationContext.xml]
      18:38:18,402 INFO [XmlWebApplicationContext] Bean factory for application context [org.springframework.web.context.support.XmlWebApplicatio
      nContext@45325f]: org.springframework.beans.factory.support.DefaultListableBeanFactory@181191f
      18:38:18,519 INFO [DefaultListableBeanFactory] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBea
      nFactory@181191f: defining beans [org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.config.internalTra
      nsactionAdvisor,dataSource,transactionManager,userManager,labManager,divisionManager,userDao,labDao,divisionDao]; root of factory hierarchy
      18:38:18,600 INFO [DriverManagerDataSource] Loaded JDBC driver: com.mysql.jdbc.Driver
      18:38:18,804 INFO [ContextLoader] Root WebApplicationContext: initialization completed in 1036 ms



      18:38:18,827 INFO [PackagesResourceConfig] Scanning for root resource and provider classes in the packages:
      com.movensis.cisl.ncarUsers.presentation.rrh
      18:38:18,840 WARNING [AnnotatedClassScanner] URL, vfszip:/C:/jboss-5.1.0.GA/server/default/deploy/WSSandBox.war/WEB-INF/classes/com/movensis
      /cisl/ncarUsers/presentation/rrh/, is ignored, it not a file or a jar file URL
      18:38:18,954 WARNING [WebApplicationImpl] The class, class com.sun.jersey.server.impl.container.servlet.JSPTemplateProcessor, registered as
      a provider class of the ResourceConfig is not annotationed with interface javax.ws.rs.ext.Provider. This class will be ignored




      18:38:18,956 ERROR [[/jersey]] StandardWrapper.Throwable
      java.lang.UnsupportedOperationException
      at java.util.Collections$UnmodifiableCollection$1.remove(Unknown Source)
      at com.sun.jersey.impl.application.WebApplicationImpl.verifyResourceConfig(WebApplicationImpl.java:705)
      at com.sun.jersey.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:506)
      at com.sun.jersey.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:472)
      at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:377)
      at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:242)
      at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:455)
      at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:178)

      Thanks,

      Bruno

        • 1. Re: RESTful WS with Jersey problem on Jboss only.. ?
          Bruno Lopes Newbie

          I changed jersey servlet property on web.xml to


          <servlet-name>JerseyAPI</servlet-name>
          <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
          <init-param>
          <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
          <param-value>com.sun.jersey.api.core.PackagesResourceConfig</param-value>
          </init-param>
          <init-param>
          <param-name>com.sun.jersey.config.property.packages</param-name>
          <param-value>lib/WSSandBox.jar</param-value>
          </init-param>
          <load-on-startup>1</load-on-startup>


          even with this change I have the same problem:

          10:34:55,553 INFO [ContextLoader] Root WebApplicationContext: initialization completed in 2121 ms
          10:34:55,581 INFO [PackagesResourceConfig] Scanning for root resource and provider classes in the packages:
          lib/WSSandBox.jar
          10:34:55,705 INFO [WebApplicationImpl] Initiating Jersey application, version 'Jersey: 1.1.1-ea 07/14/2009 07:16 PM'
          10:34:56,391 SEVERE [WebApplicationImpl] The ResourceConfig instance does not contain any root resource classes.
          10:34:56,394 ERROR [[/jboss]] StandardWrapper.Throwable
          com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
          at com.sun.jersey.server.impl.application.WebApplicationImpl.processRootResources(WebApplicationImpl.java:773)
          at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:645)
          at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:419)
          at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:377)
          at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:242)

          Any ideias ?
          Thanks Bruno

          • 2. Re: RESTful WS with Jersey problem on Jboss only.. ?
            Bruno Lopes Newbie

            The class I have on that jar is the same as before

            ...
            import javax.ws.rs.Consumes;
            import javax.ws.rs.GET;
            import javax.ws.rs.PUT;
            import javax.ws.rs.Path;
            import javax.ws.rs.PathParam;
            import javax.ws.rs.Produces;
            import javax.ws.rs.WebApplicationException;
            import javax.ws.rs.core.Context;
            import javax.ws.rs.core.Response;
            import javax.ws.rs.core.SecurityContext;
            import javax.ws.rs.core.UriInfo;
            import javax.ws.rs.core.Response.ResponseBuilder;
            import javax.ws.rs.core.Response.Status;

            import org.codehaus.jettison.json.JSONArray;
            import org.codehaus.jettison.json.JSONException;
            import org.codehaus.jettison.json.JSONObject;
            import org.restlet.data.Form;
            import org.restlet.representation.Representation;
            import org.restlet.resource.ClientResource;

            @Path("/users/")
            public class UsersResourceImpl {

            protected @Context
            UriInfo uriInfo;

            protected @Context SecurityContext securityContext;

            //protected @Request Request;

            protected UserManager userManager;
            protected DivisionManager divisionManager;
            protected LabManager labManager;

            public UsersResourceImpl() {
            userManager = (UserManager) BeanFactory.getInstance().getBean("userManager");
            divisionManager = (DivisionManager)BeanFactory.getInstance().getBean("divisionManager");
            labManager = (LabManager)BeanFactory.getInstance().getBean("labManager");
            }

            @GET
            @Path("{userName}/")
            @Produces("application/xml")
            public User getUser(@PathParam("userName")
            String userName) {

            User user = userManager.getUser(userName);
            if (null == user) {
            ResponseBuilder builder = Response.status(Status.NOT_FOUND);
            builder.type("text/html");
            builder.entity("<h3>Order Not Found</h3>");
            throw new WebApplicationException(builder.build());
            }

            return user;
            }

            @GET
            @Produces("application/object")
            @Path("/allusers")
            public List getUsers() {

            return userManager.getAllUsers();
            }

            ...
            }