3 Replies Latest reply on Dec 6, 2012 3:10 AM by vineet.reynolds

    Can't deploy Rest App to Managed Glassfish

    pogopaule

      Hi!

       

      I created a simple java ee REST project: git://github.com/pogopaule/ArquillianTest.git

      If I uses the embedded glassfish for this test (comment in the embedded glassfish and change managed to embedded in row 45 of pom.xml), the test passes.

      If I run the test as it is (that is with a managed glassfish) the deployment to the managed glassfish fails. In the server.log I see this exception:

       

      [#|2012-12-05T10:28:50.401+0100|SEVERE|glassfish3.1.2|com.sun.jersey.spi.container.ContainerResponse|_ThreadID=41;_ThreadName=Thread-2;|Mapped exception to response: 500 (Internal Server Error)
      javax.ws.rs.WebApplicationException: java.lang.NullPointerException
          at org.glassfish.admin.rest.resources.TemplateListOfResource.createResource(TemplateListOfResource.java:340)
          at org.glassfish.admin.rest.resources.TemplateListOfResource.post(TemplateListOfResource.java:180)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:601)
          at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
          at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
          at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
          at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
          at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134)
          at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
          at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134)
          at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
          at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
          at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
          at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
          at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
          at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
          at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
          at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
          at com.sun.jersey.server.impl.container.grizzly.GrizzlyContainer._service(GrizzlyContainer.java:182)
          at com.sun.jersey.server.impl.container.grizzly.GrizzlyContainer.service(GrizzlyContainer.java:147)
          at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:148)
          at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
          at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
          at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
          at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
          at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
          at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
          at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
          at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
          at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
          at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
          at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
          at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
          at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
          at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
          at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
          at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
          at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
          at java.lang.Thread.run(Thread.java:722)
      Caused by: java.lang.NullPointerException
          at org.glassfish.admin.rest.resources.TemplateListOfResource.createResource(TemplateListOfResource.java:309)
          ... 41 more
      

       

      So does anyone has a solution to this problem?

       

      Thank you,

      Fabian

        • 1. Re: Can't deploy Rest App to Managed Glassfish
          vineet.reynolds

          That problem occurs when you don't provide a file extension to your ShrinkWrap archive. Your current ShrinkWrap deployment has no file extension:

           

          @Deployment

          public static WebArchive createDeployment()

          {

          final WebArchive archive = ShrinkWrap.create( WebArchive.class, "ArquillianTest" ) // A file named ArquillianTest would be deployed.

          .addClass( RestService.class )

          .setWebXML( new File( WEBAPP_SRC, "WEB-INF/web.xml" ) );

          return archive;

          }

           

          Naming it to "ArquillianTest.war" instead of "ArquillianTest" should resolve the deployment issue.

           

          Also, you may want to inject the contextroot URL as an @ArquillianResource annotated field since the embedded and managed glassfish instances listen on different ports.

          • 2. Re: Can't deploy Rest App to Managed Glassfish
            pogopaule

            Vineet, you made my day! Thank you!

             

            Do you think there should be a warning message if someone forgets to add the extension? Shall I open a improvement ticket?

            • 3. Re: Can't deploy Rest App to Managed Glassfish
              vineet.reynolds

              Yes, you can open a feature request. We'll have to see where this can be fixed, or whether we could do with generating a warning.