cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Reinhard Pötz <reinh...@apache.org>
Subject Re: ServletSource outside of pipeline
Date Mon, 04 Aug 2008 12:24:57 GMT
Reinhard Pötz wrote:
> Robin Wyles wrote:
>> Hi,
>>
>> I have a component in my app that uses SourceResolver to create a 
>> ServletSource. When I call this component from within a pipeline, e.g. 
>> from flow or from a sitemap component all works well. However, when I 
>> call this method from a cron job I get the following NPE:
>>
>> java.lang.NullPointerException
>>     at 
>> org.apache.cocoon.callstack.environment.CallFrameHelper.getContext(CallFrameHelper.java:75)

>>
>>     at 
>> org.apache.cocoon.servletservice.CallStackHelper.getCurrentServletContext(CallStackHelper.java:112)

>>
>>     at 
>> org.apache.cocoon.servletservice.components.ServletSource.createServletConnection(ServletSource.java:125)

>>
> 
> <snip/>
> 
>> The root problem seems to be that the CallStack is empty and so the 
>> the current ServletContext cannot be obtained using 
>> CallStackHelper.getCurrentServletContext().
>>
>> Am I doing anything wrong?
> 
> IMO no. From a quick glance at the code I think it needs to be more 
> defensive in terms of catching NPEs. In the case that there is no 
> existing call frame, null should be returned. Grzegorz, what do you think?
> 

I've just committed a fix for this (revision 682356) so that *absolute* 
servlet URLs *should* work. (It can never work for self-referenced 
servlet URLs or relative servlet URLs without an existing servlet 
service request.)

Unfortunately I don't have a test case and currently no idea how I can 
provide a simple environment. This means that I'm not sure if there are 
other locations that have a problem if there is no existing servlet 
service requuest.

Any ideas for a test environment?

-- 
Reinhard Pötz                           Managing Director, {Indoqa} GmbH
                          http://www.indoqa.com/en/people/reinhard.poetz/

Member of the Apache Software Foundation
Apache Cocoon Committer, PMC member                  reinhard@apache.org
________________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message