You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Reinhard Poetz <re...@apache.org> on 2006/12/27 13:48:11 UTC
Trunk broken?
Does anybody else see this error message when he tries to use the latest
snapshot from trunk?
java.lang.NullPointerException
at
org.apache.cocoon.core.container.spring.avalon.PoolableProxyHandler.invoke(PoolableProxyHandler.java:50)
at $Proxy1.putBackIntoAvalonPool(Unknown Source)
at
org.apache.cocoon.core.container.spring.avalon.AvalonServiceManager.release(AvalonServiceManager.java:73)
at
org.apache.cocoon.components.treeprocessor.TreeProcessor.buildConcreteProcessor(TreeProcessor.java:410)
at
org.apache.cocoon.components.treeprocessor.TreeProcessor.setupConcreteProcessor(TreeProcessor.java:324)
at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:232)
at org.apache.cocoon.servlet.RequestProcessor.process(RequestProcessor.java:328)
at org.apache.cocoon.servlet.RequestProcessor.service(RequestProcessor.java:155)
at org.apache.cocoon.sitemap.SitemapServlet.service(SitemapServlet.java:61)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.cocoon.blocks.BlockContext$PathDispatcher.forward(BlockContext.java:461)
at
org.apache.cocoon.blocks.BlockContext$PathDispatcher.forward(BlockContext.java:443)
at org.apache.cocoon.blocks.BlockServlet.service(BlockServlet.java:123)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.cocoon.blocks.DispatcherServlet.service(DispatcherServlet.java:126)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.cocoon.servlet.ReloadingServlet.service(ReloadingServlet.java:93)
Line 50 of the PoolableProxyHandler is
RequestContextHolder.getRequestAttributes().removeAttribute(this.attributeName,
RequestAttributes.SCOPE_REQUEST);
--
Reinhard Pötz Independent Consultant, Trainer & (IT)-Coach
{Software Engineering, Open Source, Web Applications, Apache Cocoon}
web(log): http://www.poetz.cc
--------------------------------------------------------------------
___________________________________________________________
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Re: Trunk broken?
Posted by Carsten Ziegeler <cz...@apache.org>.
Joerg Heinicke schrieb:
> On 27.12.2006 14:03, Carsten Ziegeler wrote:
>
>>>> Line 50 of the PoolableProxyHandler is
>>>>
>>>> RequestContextHolder.getRequestAttributes().removeAttribute(this.attributeName,
>>>> RequestAttributes.SCOPE_REQUEST);
>
>> I removed our own implementation in favour of Spring's
>> RequestContextHolder. The attributes are used to keep track of poolable
>> components and to release them when the request is finished.
>> Therefore you should add the Spring's request context listener to your
>> web.xml (I added it to web.xml in svn); this listener requires servlet
>> spec 2.4.
>
> Wouldn't it be better to use
> RequestContextHolder.currentRequestAttributes() (instead of
> getRequestAttributes()) then? It has an additional null check and fails
> early with an IllegalStateException with a quite clear error message.
> This prevents NPEs like the one above.
>
Yes, you're right. I used this approach in the rest of our code (at
least I *think* I used it...) :)
Carsten
--
Carsten Ziegeler - Chief Architect
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/
Re: Trunk broken?
Posted by Joerg Heinicke <jo...@gmx.de>.
On 27.12.2006 14:03, Carsten Ziegeler wrote:
>>> Line 50 of the PoolableProxyHandler is
>>>
>>> RequestContextHolder.getRequestAttributes().removeAttribute(this.attributeName,
>>> RequestAttributes.SCOPE_REQUEST);
> I removed our own implementation in favour of Spring's
> RequestContextHolder. The attributes are used to keep track of poolable
> components and to release them when the request is finished.
> Therefore you should add the Spring's request context listener to your
> web.xml (I added it to web.xml in svn); this listener requires servlet
> spec 2.4.
Wouldn't it be better to use
RequestContextHolder.currentRequestAttributes() (instead of
getRequestAttributes()) then? It has an additional null check and fails
early with an IllegalStateException with a quite clear error message.
This prevents NPEs like the one above.
Jörg
Re: Trunk broken?
Posted by Joerg Heinicke <jo...@gmx.de>.
On 27.12.2006 19:05, Reinhard Poetz wrote:
>> I removed our own implementation in favour of Spring's
>> RequestContextHolder. The attributes are used to keep track of poolable
>> components and to release them when the request is finished.
>> Therefore you should add the Spring's request context listener to your
>> web.xml (I added it to web.xml in svn); this listener requires servlet
>> spec 2.4.
>
> For some reasons the use of the
> org.springframework.web.context.request.RequestContextListener caused
> this exception:
>
> java.lang.IllegalStateException: No thread-bound request found: Are you
> referring to request attributes outside of an actual web request? If you
> are actually operating within a web request and still receive this
> message,your code is probably running outside of
> DispatcherServlet/DispatcherPortlet: In this case, use
> RequestContextListener or RequestContextFilter to expose the current
> request.
That's the descriptive exception I talked about when
RequestContextHolder does actually not hold a RequestAttributes
instance. It's caused by the mentioned null check instead of the NPE you
got.
If you use web.xml as is (the one you committed, [1]) the Listener does
not work because of servlet 2.3 while you need 2.4. IIRC we decided to
switch to 2.4, so it would be better to change the DTD/schema
declaration to 2.4 in that web.xml.
Regards
Jörg
[1]
http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/resources/org/apache/cocoon/maven/rcl/WEB-INF/web.xml?revision=490547&view=markup&pathrev=490547
Re: Trunk broken?
Posted by Philipp Zerelles <ph...@moongate.de>.
Well, I created the eclipse project using "mvn eclipse:eclipse". Then I
imported it into my workspace (btw, I ony use the webapp now with the
SitemapServlet) and configured the Jetty Launcher to use my Jetty 5.1.12
installation (that defaults to Servlet 2.4, too) and set the webapp root
to "src/main/webapp". My webapp contains a web.xml file that is set to use
2.4 Servlets.
Then I start to debug, jetty starts and I get the error message when
accessing "/".
On Thursday 28 December 2006 18:25, Reinhard Poetz wrote:
> Philipp Zerelles wrote:
> > I just created a new webapp and block using the archetypes from trunk and
> > I get the same error when using the Jetty-Eclipse-Plugin to run the
> > webapp:
> >
> > java.lang.IllegalStateException: No thread-bound request found: Are you
> > referring to request attributes outside of an actual web request? If you
> > are actually operating within a web request and still receive this
> > message,your code is probably running outside of
> > DispatcherServlet/DispatcherPortlet: In this case, use
> > RequestContextListener or RequestContextFilter to expose the current
> > request.
> >
> > When I run it using maven, it works without problem. Any idea why it does
> > not work with eclipse?
>
> Are you sure that the web.xml, that is used, contains the listener (or
> filter) and is set to version 2.4 as suggested by Jörg and Carsten?
Re: Trunk broken?
Posted by Reinhard Poetz <re...@apache.org>.
Philipp Zerelles wrote:
> I just created a new webapp and block using the archetypes from trunk and I
> get the same error when using the Jetty-Eclipse-Plugin to run the webapp:
>
> java.lang.IllegalStateException: No thread-bound request found: Are you
> referring to request attributes outside of an actual web request? If you are
> actually operating within a web request and still receive this message,your
> code is probably running outside of DispatcherServlet/DispatcherPortlet: In
> this case, use RequestContextListener or RequestContextFilter to expose the
> current request.
>
> When I run it using maven, it works without problem. Any idea why it does not
> work with eclipse?
Are you sure that the web.xml, that is used, contains the listener (or filter)
and is set to version 2.4 as suggested by Jörg and Carsten?
--
Reinhard Pötz Independent Consultant, Trainer & (IT)-Coach
{Software Engineering, Open Source, Web Applications, Apache Cocoon}
web(log): http://www.poetz.cc
--------------------------------------------------------------------
Re: Trunk broken?
Posted by Philipp Zerelles <ph...@moongate.de>.
I just created a new webapp and block using the archetypes from trunk and I
get the same error when using the Jetty-Eclipse-Plugin to run the webapp:
java.lang.IllegalStateException: No thread-bound request found: Are you
referring to request attributes outside of an actual web request? If you are
actually operating within a web request and still receive this message,your
code is probably running outside of DispatcherServlet/DispatcherPortlet: In
this case, use RequestContextListener or RequestContextFilter to expose the
current request.
When I run it using maven, it works without problem. Any idea why it does not
work with eclipse?
On Thursday 28 December 2006 08:59, Reinhard Poetz wrote:
> Carsten Ziegeler wrote:
> > Reinhard Poetz wrote:
> >> Thanks Carsten and Jörg! After adding the
> >> org.springframework.web.filter.RequestContextFilter, the reloading
> >> classloader (works like the shielded cl) works for me again.
> >>
> >> For some reasons the use of the
> >> org.springframework.web.context.request.RequestContextListener caused
> >> this exception:
> >>
> >> java.lang.IllegalStateException: No thread-bound request found: Are you
> >> referring to request attributes outside of an actual web request? If you
> >> are actually operating within a web request and still receive this
> >> message,your code is probably running outside of
> >> DispatcherServlet/DispatcherPortlet: In this case, use
> >> RequestContextListener or RequestContextFilter to expose the current
> >> request.
> >>
> >> Don't know what's wrong here, but I won't investigate further because
> >> together with the manipulation of the classloading mechanism like the
> >> reloading classloader does, things are often difficult to debug at that
> >> level.
> >
> > I guess you're still using 2.3 of the servlet spec; you have to adjust
> > your web.xml in order to use 2.4. Have a look at the sample web.xml in
> > the core-webapp module.
>
> thanks. I forgot that the change of the servlet spec also manifests in the
> web.xml and updating the jar is not enough.
Re: Trunk broken?
Posted by Reinhard Poetz <re...@apache.org>.
Carsten Ziegeler wrote:
> Reinhard Poetz wrote:
>
>> Thanks Carsten and Jörg! After adding the
>> org.springframework.web.filter.RequestContextFilter, the reloading classloader
>> (works like the shielded cl) works for me again.
>>
>> For some reasons the use of the
>> org.springframework.web.context.request.RequestContextListener caused this
>> exception:
>>
>> java.lang.IllegalStateException: No thread-bound request found: Are you
>> referring to request attributes outside of an actual web request? If you are
>> actually operating within a web request and still receive this message,your code
>> is probably running outside of DispatcherServlet/DispatcherPortlet: In this
>> case, use RequestContextListener or RequestContextFilter to expose the current
>> request.
>>
>> Don't know what's wrong here, but I won't investigate further because together
>> with the manipulation of the classloading mechanism like the reloading
>> classloader does, things are often difficult to debug at that level.
>>
> I guess you're still using 2.3 of the servlet spec; you have to adjust
> your web.xml in order to use 2.4. Have a look at the sample web.xml in
> the core-webapp module.
thanks. I forgot that the change of the servlet spec also manifests in the
web.xml and updating the jar is not enough.
--
Reinhard Pötz Independent Consultant, Trainer & (IT)-Coach
{Software Engineering, Open Source, Web Applications, Apache Cocoon}
web(log): http://www.poetz.cc
--------------------------------------------------------------------
___________________________________________________________
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Re: Trunk broken?
Posted by Carsten Ziegeler <cz...@apache.org>.
Reinhard Poetz wrote:
>
> Thanks Carsten and Jörg! After adding the
> org.springframework.web.filter.RequestContextFilter, the reloading classloader
> (works like the shielded cl) works for me again.
>
> For some reasons the use of the
> org.springframework.web.context.request.RequestContextListener caused this
> exception:
>
> java.lang.IllegalStateException: No thread-bound request found: Are you
> referring to request attributes outside of an actual web request? If you are
> actually operating within a web request and still receive this message,your code
> is probably running outside of DispatcherServlet/DispatcherPortlet: In this
> case, use RequestContextListener or RequestContextFilter to expose the current
> request.
>
> Don't know what's wrong here, but I won't investigate further because together
> with the manipulation of the classloading mechanism like the reloading
> classloader does, things are often difficult to debug at that level.
>
I guess you're still using 2.3 of the servlet spec; you have to adjust
your web.xml in order to use 2.4. Have a look at the sample web.xml in
the core-webapp module.
HTH
Carsten
--
Carsten Ziegeler - Chief Architect
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/
Re: Trunk broken?
Posted by Reinhard Poetz <re...@apache.org>.
Carsten Ziegeler wrote:
> Joerg Heinicke wrote:
>> On 27.12.2006 13:48, Reinhard Poetz wrote:
>>
>>> Does anybody else see this error message when he tries to use the latest
>>> snapshot from trunk?
>>>
>>> java.lang.NullPointerException
>>> at
>>> org.apache.cocoon.core.container.spring.avalon.PoolableProxyHandler.invoke(PoolableProxyHandler.java:50)
>>>
>>>
>>> Line 50 of the PoolableProxyHandler is
>>>
>>> RequestContextHolder.getRequestAttributes().removeAttribute(this.attributeName,
>>> RequestAttributes.SCOPE_REQUEST);
>> Don't know about Cocoon trunk yet, but if RequestContextHolder is the
>> one delivered with Spring you need a component setting the
>> RequestAttributes on the RequestContextHolder. Therefore you can use
>> RequestContextListener or RequestContextFilter and declare it in web.xml.
>>
> Exactly :)
> I removed our own implementation in favour of Spring's
> RequestContextHolder. The attributes are used to keep track of poolable
> components and to release them when the request is finished.
> Therefore you should add the Spring's request context listener to your
> web.xml (I added it to web.xml in svn); this listener requires servlet
> spec 2.4.
Thanks Carsten and Jörg! After adding the
org.springframework.web.filter.RequestContextFilter, the reloading classloader
(works like the shielded cl) works for me again.
For some reasons the use of the
org.springframework.web.context.request.RequestContextListener caused this
exception:
java.lang.IllegalStateException: No thread-bound request found: Are you
referring to request attributes outside of an actual web request? If you are
actually operating within a web request and still receive this message,your code
is probably running outside of DispatcherServlet/DispatcherPortlet: In this
case, use RequestContextListener or RequestContextFilter to expose the current
request.
Don't know what's wrong here, but I won't investigate further because together
with the manipulation of the classloading mechanism like the reloading
classloader does, things are often difficult to debug at that level.
--
Reinhard Pötz Independent Consultant, Trainer & (IT)-Coach
{Software Engineering, Open Source, Web Applications, Apache Cocoon}
web(log): http://www.poetz.cc
--------------------------------------------------------------------
___________________________________________________________
Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Re: Trunk broken?
Posted by Carsten Ziegeler <cz...@apache.org>.
Joerg Heinicke wrote:
> On 27.12.2006 13:48, Reinhard Poetz wrote:
>
>> Does anybody else see this error message when he tries to use the latest
>> snapshot from trunk?
>>
>> java.lang.NullPointerException
>> at
>> org.apache.cocoon.core.container.spring.avalon.PoolableProxyHandler.invoke(PoolableProxyHandler.java:50)
>>
>>
>> Line 50 of the PoolableProxyHandler is
>>
>> RequestContextHolder.getRequestAttributes().removeAttribute(this.attributeName,
>> RequestAttributes.SCOPE_REQUEST);
>
> Don't know about Cocoon trunk yet, but if RequestContextHolder is the
> one delivered with Spring you need a component setting the
> RequestAttributes on the RequestContextHolder. Therefore you can use
> RequestContextListener or RequestContextFilter and declare it in web.xml.
>
Exactly :)
I removed our own implementation in favour of Spring's
RequestContextHolder. The attributes are used to keep track of poolable
components and to release them when the request is finished.
Therefore you should add the Spring's request context listener to your
web.xml (I added it to web.xml in svn); this listener requires servlet
spec 2.4.
Carsten
--
Carsten Ziegeler - Chief Architect
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/
Re: Trunk broken?
Posted by Joerg Heinicke <jo...@gmx.de>.
On 27.12.2006 13:48, Reinhard Poetz wrote:
> Does anybody else see this error message when he tries to use the latest
> snapshot from trunk?
>
> java.lang.NullPointerException
> at
> org.apache.cocoon.core.container.spring.avalon.PoolableProxyHandler.invoke(PoolableProxyHandler.java:50)
>
>
> Line 50 of the PoolableProxyHandler is
>
> RequestContextHolder.getRequestAttributes().removeAttribute(this.attributeName,
> RequestAttributes.SCOPE_REQUEST);
Don't know about Cocoon trunk yet, but if RequestContextHolder is the
one delivered with Spring you need a component setting the
RequestAttributes on the RequestContextHolder. Therefore you can use
RequestContextListener or RequestContextFilter and declare it in web.xml.
Jörg