users@jersey.java.net

Re: [Jersey] 0.6 -> 0.7 problem with jetty

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 05 Jun 2008 18:05:02 +0200

Jean Aurambault wrote:
> Hi Paul,
>
> I have already seen this thread and I don't think this is the problem.
> It might be my jetty configuration which is not compliant with the
> Jersey's SpringServlet. I change mine to make it work following your
> recommendation about the ComponentProvider.getInjectableInstance.

OK.


> That's
> a bad solution but I don't have much time right now and I don't know
> much about jetty ...
>

Me neither.

I looked at your code and i cannot see much difference to that of the
test code. You are using a context listener, the test code is using a
servlet instead, but i changed the test code to use a context listener,
and it worked just fine i.e. the modified test jetty init code was the
same in structure as yours.

Perhaps it is a pom issue? the pom [1] supports both 2.0.5 and 2.5.2 and
is based on profiles "spring20" and "spring25" respectively (the latter
is the default).

Paul.

[1]
http://download.java.net/maven/2/com/sun/jersey/jersey-spring/0.8-ea-SNAPSHOT/jersey-spring-0.8-ea-SNAPSHOT.pom


> thanks for your help,
>
> Jean.
>
> Paul Sandoz wrote:
>> Hi Jean,
>>
>> Do you have multiple spring jars in your classpath?
>>
>> See here:
>>
>> http://forum.springframework.org/archive/index.php/t-11230.html
>>
>> Paul.
>>
>> Jean Aurambault wrote:
>>> My mistake I was trying to use jersey's SpringServlet and my unit
>>> tests were still using the old I had in the project...
>>>
>>> Anyway using jersey's springServlet,I have now a problem related to
>>> WebApplicationContext:
>>>
>>> java.lang.IllegalStateException: Root context attribute is not of
>>> type WebApplicationContext:
>>> org.springframework.web.context.support.XmlWebApplicationContext_at_11fb8c6:
>>> display name [Root WebApplicationContext]; startup date [Thu Jun 05
>>> 11:17:55 CEST 2008]; root of context hierarchy
>>> at
>>> org.springframework.web.context.support.WebApplicationContextUtils.getWebApplicationContext(WebApplicationContextUtils.java:75)
>>>
>>> at
>>> org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:93)
>>>
>>> at
>>> com.sun.jersey.spi.spring.container.servlet.SpringServlet.initiate(SpringServlet.java:146)
>>>
>>> at
>>> com.sun.jersey.spi.container.servlet.ServletContainer.load(ServletContainer.java:328)
>>>
>>> at
>>> com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:136)
>>>
>>> at
>>> org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:433)
>>>
>>> at
>>> org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:342)
>>>
>>> at
>>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:463)
>>> at
>>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
>>> at
>>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>>> at
>>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
>>> at
>>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
>>> at org.mortbay.jetty.Server.handle(Server.java:313)
>>> at
>>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
>>> at
>>> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:830)
>>>
>>> at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
>>> at
>>> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
>>> at
>>> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
>>> at
>>> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:227)
>>>
>>> at
>>> org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)
>>>
>>>
>>> Here is my configuration for Jetty:
>>>
>>> ServletHolder serveHolder = new
>>> ServletHolder(SpringServlet.class);
>>> serveHolder.setInitParameter(
>>> "com.sun.jersey.config.property.resourceConfigClass",
>>> "com.sun.jersey.api.core.PackagesResourceConfig");
>>>
>>> serveHolder.setInitParameter("com.sun.jersey.config.property.packages",
>>> "com.yahoo.l10nservice.resources;com.yahoo.l10nservice.providers");
>>> server = new Server(port);
>>> Context context = new Context(server, "/", Context.SESSIONS);
>>> ContextLoaderListener listener = new ContextLoaderListener();
>>> context.addEventListener(listener);
>>> context.setResourceBase("src/test/resources");
>>> context.getInitParams().put("contextConfigLocation",
>>> "classpath:applicationContext.xml
>>> classpath:applicationContextTest.xml");
>>> context.addServlet(serveHolder, "/*");
>>>
>>> Jean.
>>>
>>>
>>> Paul Sandoz wrote:
>>>> Hi Jean,
>>>>
>>>> Are you using a custom ComponentProvider? If so is the method
>>>>
>>>> ComponentProvider.getInjectableInstance
>>>>
>>>> returning null ? If so can you modify it to return the single method
>>>> parameter.
>>>>
>>>> If not can you send the code for the root resource class in question?
>>>>
>>>> Paul.
>>>>
>>>> Jean Aurambault wrote:
>>>>> Hi all,
>>>>>
>>>>> I tried the 0.8 snapshot and now I have another error !! any idea?
>>>>>
>>>>> java.lang.NullPointerException
>>>>> at
>>>>> sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:36)
>>>>>
>>>>> at
>>>>> sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18)
>>>>>
>>>>> at java.lang.reflect.Field.get(Field.java:358)
>>>>> at
>>>>> com.sun.jersey.spi.resource.ResourceClassInjector.inject(ResourceClassInjector.java:270)
>>>>>
>>>>> at
>>>>> com.sun.jersey.impl.resource.SingletonProvider.init(SingletonProvider.java:69)
>>>>>
>>>>> at
>>>>> com.sun.jersey.spi.resource.ResourceProviderFactory.createProvider(ResourceProviderFactory.java:132)
>>>>>
>>>>> at
>>>>> com.sun.jersey.impl.model.ResourceClass.init(ResourceClass.java:174)
>>>>> at
>>>>> com.sun.jersey.impl.application.WebApplicationImpl.getResourceClass(WebApplicationImpl.java:250)
>>>>>
>>>>> at
>>>>> com.sun.jersey.impl.application.WebApplicationImpl.processRootResources(WebApplicationImpl.java:681)
>>>>>
>>>>> at
>>>>> com.sun.jersey.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:568)
>>>>>
>>>>> at
>>>>> com.yahoo.l10nservice.servlet.SpringServlet.initiate(SpringServlet.java:108)
>>>>>
>>>>> at
>>>>> com.sun.jersey.spi.container.servlet.ServletContainer.load(ServletContainer.java:328)
>>>>>
>>>>> at
>>>>> com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:136)
>>>>>
>>>>> at
>>>>> org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:433)
>>>>>
>>>>> at
>>>>> org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:342)
>>>>>
>>>>> at
>>>>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:463)
>>>>> at
>>>>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
>>>>>
>>>>> at
>>>>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>>>>>
>>>>> at
>>>>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
>>>>>
>>>>> at
>>>>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
>>>>>
>>>>> at org.mortbay.jetty.Server.handle(Server.java:313)
>>>>> at
>>>>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
>>>>>
>>>>> at
>>>>> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:830)
>>>>>
>>>>> at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
>>>>> at
>>>>> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
>>>>> at
>>>>> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
>>>>> at
>>>>> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:227)
>>>>>
>>>>> at
>>>>> org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)
>>>>>
>>>>>
>>>>> Jean.
>>>>>
>>>>>
>>>>> Paul Sandoz wrote:
>>>>>> Lars Tackmann wrote:
>>>>>>> On Tue, Jun 3, 2008 at 5:52 PM, Paul Sandoz <Paul.Sandoz_at_sun.com>
>>>>>>> wrote:
>>>>>>>> I wonder if it is my fault. This is the rather embarrassing
>>>>>>>> piece of code:
>>>>>>>>
>>>>>>>> public BaseRule(UriTemplate template) {
>>>>>>>> assert template != template; <- !!!!!!!!!!!!
>>>>>>>>
>>>>>>>> this.template = template;
>>>>>>>> }
>>>>>>>>
>>>>>>>> Find bugs spotted it, but i did not spot that find bugs did
>>>>>>>> until after 0.7
>>>>>>>> was released. However, it seemed to be benign and did not result
>>>>>>>> in any
>>>>>>>> failures to unit tests or running the examples, otherwise i
>>>>>>>> would have
>>>>>>>> noticed and fixed it immediately.
>>>>>>>
>>>>>>> Indeed it is fixed in the latest maven pom snapshot, which can be
>>>>>>> obatined by adding the following lines to pom.xml
>>>>>>>
>>>>>>
>>>>>> Great. Glad the maven stuff is working :-)
>>>>>>
>>>>>> 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 question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109