users@jersey.java.net

Re: [Jersey] Jersey/JAX-RS integration with Servlet 3.0

From: Naresh <Srinivas.Bhimisetty_at_Sun.COM>
Date: Mon, 07 Sep 2009 15:40:47 +0530

Paul Sandoz wrote:
> Hi,
>
> This may be an installation problem.
>
> Did you modify the pom.xml of the samples so that jersey dependencies
> are in the scope of provided?
I did not see that the jersey dependency was in the default scope,
modifying the scope to "provided" did the trick. It works now.
>
> The latter exception is a fundamental error implying something is
> wrong with the installation. Do you also get such a ClassCastException
> for OneApplication as well, before the NullPointerException when that
> application is serviced?
Yes, the ClassCastException came before the NullPointerException.
However, it works fine now, upon correcting the scope.

Thanks,
Naresh
>
> Can you send me the complete log?
>
> It seems that the servlet 3.0 layer may still be utilizing the servlet
> even though the initialization failed.
>
> Paul.
>
> On Sep 7, 2009, at 10:58 AM, Naresh wrote:
>
>> Naresh wrote:
>>> Naresh wrote:
>>>> Hi Paul,
>>>>
>>>> I have deployed the prelimaryapp sample on GF v3 b61.
>>>> But the URL http://localhost:8080/preliminaryapp/oneonly/one gives
>>>> a 404. Am I missing something?
>>> Please ignore. I forgot updating Jersey.
>> I have updated the Jersey jars by unzipping [1] to the glassfishv3
>> folder.
>> Upon updating, I see the following null pointer exceptions for [2] :
>>
>> ----------------------------------------------------------------------------------------
>>
>> [#|2009-09-07T14:18:26.513+0530|WARNING|glassfish|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=25;_ThreadName=Thread-2;|StandardWrapperValve[com.sun.jersey.samples.servlet3.preliminaryapp.OneApplication]:
>> PWC1406: Servlet.service() for servlet
>> com.sun.jersey.samples.servlet3.preliminaryapp.OneApplication threw
>> exception
>> java.lang.NullPointerException
>> at
>> com.sun.jersey.spi.container.ContainerRequest.<init>(ContainerRequest.java:172)
>>
>> at
>> com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:302)
>>
>> at
>> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:452)
>>
>> at
>> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:633)
>>
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
>> at
>> org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1505)
>>
>> at
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:293)
>>
>> at
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
>>
>> at
>> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
>>
>> at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
>> at
>> com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
>>
>> at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
>>
>> at
>> org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:341)
>>
>> at
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:237)
>>
>> at
>> com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:202)
>>
>> at
>> com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:752)
>> at
>> com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:660)
>> at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:911)
>> at
>> com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:164)
>>
>> at
>> com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
>>
>> at
>> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
>>
>> at
>> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
>>
>> at
>> com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
>>
>> at
>> com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
>>
>> at
>> com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
>>
>> at com.sun.grizzly.NIOContext.execute(NIOContext.java:510)
>> at
>> com.sun.grizzly.SelectorHandlerRunner.handleSelectedKey(SelectorHandlerRunner.java:357)
>>
>> at
>> com.sun.grizzly.SelectorHandlerRunner.handleSelectedKeys(SelectorHandlerRunner.java:257)
>>
>> at
>> com.sun.grizzly.SelectorHandlerRunner.doSelect(SelectorHandlerRunner.java:194)
>>
>> at
>> com.sun.grizzly.SelectorHandlerRunner.run(SelectorHandlerRunner.java:129)
>>
>> at
>> com.sun.grizzly.util.FixedThreadPool$BasicWorker.dowork(FixedThreadPool.java:379)
>>
>> at
>> com.sun.grizzly.util.FixedThreadPool$BasicWorker.run(FixedThreadPool.java:360)
>>
>> at java.lang.Thread.run(Thread.java:619)
>> |#]
>> ----------------------------------------------------------------------------------
>>
>>
>> Also, it throws some ClassCastException:
>> -------------------------------------------------------------------------------------------
>>
>> PWC1382: Allocate exception for servlet
>> com.sun.jersey.samples.servlet3.preliminaryapp.TwoApplication
>> com.sun.jersey.spi.service.ServiceConfigurationError:
>> com.sun.jersey.spi.container.WebApplicationProvider: The class
>> com.sun.jersey.server.impl.container.WebApplicationProviderImpl
>> implementing provider interface
>> com.sun.jersey.spi.container.WebApplicationProvider could not be
>> instantiated: null
>> at
>> com.sun.jersey.spi.service.ServiceFinder.fail(ServiceFinder.java:380)
>> at
>> com.sun.jersey.spi.service.ServiceFinder.access$600(ServiceFinder.java:144)
>>
>> at
>> com.sun.jersey.spi.service.ServiceFinder$LazyObjectIterator.hasNext(ServiceFinder.java:683)
>>
>> at
>> com.sun.jersey.spi.container.WebApplicationFactory.createWebApplication(WebApplicationFactory.java:61)
>>
>> at
>> com.sun.jersey.spi.container.servlet.ServletContainer.create(ServletContainer.java:326)
>>
>> at
>> com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.create(ServletContainer.java:241)
>>
>> at
>> com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:475)
>>
>> at
>> com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:196)
>>
>> at
>> com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:308)
>>
>> at
>> com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:471)
>>
>> at javax.servlet.GenericServlet.init(GenericServlet.java:242)
>> at
>> org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1410)
>>
>> at
>> org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:1056)
>>
>> at
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:201)
>>
>> at
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
>>
>> at
>> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
>>
>> at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
>> at
>> com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
>>
>> at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
>>
>> at
>> org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:341)
>>
>> at
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:237)
>>
>> at
>> com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:202)
>>
>> at
>> com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:752)
>> at
>> com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:660)
>> at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:911)
>> at
>> com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:164)
>>
>> at
>> com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
>>
>> at
>> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
>>
>> at
>> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
>>
>> at
>> com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
>>
>> at
>> com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
>>
>> at
>> com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
>>
>> at com.sun.grizzly.NIOContext.execute(NIOContext.java:510)
>> at
>> com.sun.grizzly.SelectorHandlerRunner.handleSelectedKey(SelectorHandlerRunner.java:357)
>>
>> at
>> com.sun.grizzly.SelectorHandlerRunner.handleSelectedKeys(SelectorHandlerRunner.java:257)
>>
>> at
>> com.sun.grizzly.SelectorHandlerRunner.doSelect(SelectorHandlerRunner.java:194)
>>
>> at
>> com.sun.grizzly.SelectorHandlerRunner.run(SelectorHandlerRunner.java:129)
>>
>> at
>> com.sun.grizzly.util.FixedThreadPool$BasicWorker.dowork(FixedThreadPool.java:379)
>>
>> at
>> com.sun.grizzly.util.FixedThreadPool$BasicWorker.run(FixedThreadPool.java:360)
>>
>> at java.lang.Thread.run(Thread.java:619)
>> Caused by: java.lang.ClassCastException
>> at java.lang.Class.cast(Class.java:2990)
>> at
>> com.sun.jersey.spi.service.ServiceFinder$LazyObjectIterator.hasNext(ServiceFinder.java:641)
>>
>> ... 37 more
>> ------------------------------------------------------------------------------------------
>>
>>
>> [1]
>> http://download.java.net/maven/2/com/sun/jersey/glassfish/v3/jersey-gfv3-core/1.1.3-ea-SNAPSHOT/jersey-gfv3-core-1.1.3-ea-SNAPSHOT-project.zip
>>
>> [2] http://localhost:8080/preliminaryapp/oneonly/one
>>
>> -Naresh
>>>
>>> -Naresh
>>>>
>>>> Thanks,
>>>> Naresh
>>>>
>>>> Paul Sandoz wrote:
>>>>> Hi,
>>>>>
>>>>> I have just implemented Servlet 3.0 integration into Jersey so
>>>>> that it is no longer necessary to utilize web.xml (or if utilized
>>>>> it is not necessary to declare the servlet class).
>>>>>
>>>>> To experiment you need to use Jersey 1.1.3-ea-SNAPSHOT and build
>>>>> 61 or greater of GF v3. Currently i have only tested on promoted
>>>>> build 61 of GF v3.
>>>>>
>>>>> Attached are some maven-based samples. Naresh, these samples could
>>>>> form the basis of some functional tests, but they do not fully
>>>>> cover all cases, see the following code to get an understand of
>>>>> what else needs to be tested:
>>>>>
>>>>> http://fisheye4.atlassian.com/browse/jersey/trunk/jersey/jersey-server/src/main/java/com/sun/jersey/server/impl/container/servlet/JerseyServletContainerInitializer.java?r=2735
>>>>>
>>>>>
>>>>> Jersey will use it's implementation of the Servlet 3.0
>>>>> ServletContainerInitializer interface to detect classes that
>>>>> extend from javax.ws.rs.core.Application.
>>>>>
>>>>> For example. the "annotatedapp" sample contains the following class:
>>>>>
>>>>> @ApplicationPath("/oneonly")
>>>>> public class OneApplication extends Application {
>>>>> @Override
>>>>> public Set<Class<?>> getClasses() {
>>>>> return Collections.<Class<?>>singleton(One.class);
>>>>> }
>>>>> }
>>>>>
>>>>> A Jersey servlet will be registered at the mapping "/oneonly/*"
>>>>> using OneApplication as the class that registers root resource and
>>>>> provider classes.
>>>>>
>>>>> Paul.
>>>>>
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>