NPE in ServletExternalContext.Request.getRequestURL

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

NPE in ServletExternalContext.Request.getRequestURL

jontto
Hi,

I'm calling a filtered servlet from a portlet in Jboss Portal and this leads to a NPE in ServletExternalContext.Request.getRequestURL().

In this case there is no request URL in nativeRequest and null is returned and toString() on null throws a NPE.

I just modified the code to this, but not sure it's the ultimate solution:

        public String getRequestURL() {
        StringBuffer requestUrl = nativeRequest.getRequestURL();
            return (requestUrl != null) ? requestUrl.toString(): "";
        }

Could someone verify if there should be a request url or not in the request?

// Jonas
Reply | Threaded
Open this post in threaded view
|

Re: NPE in ServletExternalContext.getRequestURL

Erik Bruchez
Administrator
Do you know which code actually requires getRequestURL() in this  
particular case?

Issue is that within a portlet, you actually don't know AFAIK the  
request URL (which is an absolute URL starting with http://...).

Just trying here to see if we should return "" or null or something  
else.

-Erik

On Feb 11, 2009, at 5:37 AM, jontto wrote:

>
> Hi,
>
> I'm calling a filtered servlet from a portlet in Jboss Portal and  
> this leads
> to a NPE in ServletExternalContext.getRequestURL().
>
> In this case there is no request URL in nativeRequest and null is  
> returned
> and toString() on null throws a NPE.
>
> I just modified the code to this, but not sure it's the ultimate  
> solution:
>
>        public String getRequestURL() {
>         StringBuffer requestUrl = nativeRequest.getRequestURL();
>            return (requestUrl != null) ? requestUrl.toString(): "";
>        }
>
> Could someone verify if there should be a request url or not in the  
> request?
>
> // Jonas
> --
> View this message in context: http://www.nabble.com/NPE-in-ServletExternalContext.getRequestURL-tp21954815p21954815.html
> Sent from the ObjectWeb OPS - Users mailing list archive at  
> Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email]  
> mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: NPE in ServletExternalContext.getRequestURL

jontto
Hi,

Sure, it's called when building the DOM of the request. I'll paste a cut out from my stack (using a 20090210 nightly):

        ServletExternalContext$Request.getRequestURL() line: 271
        RequestGenerator.readWholeRequestAsDOM4J(PipelineContext) line: 341
        RequestGenerator.readRequestAsDOM4J(PipelineContext, Node) line: 293
        RequestGenerator.access$600(RequestGenerator, PipelineContext, Node) line: 79
        RequestGenerator$1.fillOutState(PipelineContext, ProcessorImpl$DigestState) line: 213
        RequestGenerator$1(ProcessorImpl$DigestTransformerOutputImpl).getFilledOutState(PipelineContext) line: 1410
        RequestGenerator$1(ProcessorImpl$DigestTransformerOutputImpl).getLocalKey(PipelineContext) line: 1373
        RequestGenerator$1(ProcessorImpl$CacheableTransformerOutputImpl).getKeyImpl(PipelineContext) line: 1315
        ProcessorImpl$ProcessorOutputImpl$1.getKey(PipelineContext) line: 999
        RequestGenerator$1(ProcessorImpl$ProcessorOutputImpl).getKey(PipelineContext) line: 1189
        ProcessorImpl.getInputKey(PipelineContext, ProcessorInput) line: 1211
        ConcreteChooseProcessor(ProcessorImpl).getInputKeyValidity(PipelineContext, ProcessorInput) line: 1246
        ConcreteChooseProcessor(ProcessorImpl).readCacheInputAsObject(PipelineContext, ProcessorInput, CacheableInputReader) line: 438
        ConcreteChooseProcessor(ProcessorImpl).readCacheInputAsTinyTree(PipelineContext, String) line: 408
        ConcreteChooseProcessor.start(PipelineContext) line: 189
        PipelineProcessor$5.run() line: 644
        PipelineProcessor(ProcessorImpl).executeChildren(PipelineContext, Runnable) line: 519
        PipelineProcessor.start(PipelineContext) line: 641
        PipelineProcessor$5.run() line: 644
        PipelineProcessor(ProcessorImpl).executeChildren(PipelineContext, Runnable) line: 519
        PipelineProcessor.start(PipelineContext) line: 641
        ConcreteChooseProcessor.start(PipelineContext) line: 242
        PipelineProcessor$5.run() line: 644
        PipelineProcessor(ProcessorImpl).executeChildren(PipelineContext, Runnable) line: 519
        PipelineProcessor.start(PipelineContext) line: 641
        InitUtils.runProcessor(Processor, ExternalContext, PipelineContext, Logger) line: 92
        ProcessorService.service(boolean, ExternalContext, PipelineContext) line: 96
        OrbeonServletDelegate.service(HttpServletRequest, HttpServletResponse) line: 138
        OrbeonServletDelegate(HttpServlet).service(ServletRequest, ServletResponse) line: 803
        ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 290
        ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206
        ApplicationDispatcher.invoke(ServletRequest, ServletResponse, ApplicationDispatcher$State) line: 654
        ApplicationDispatcher.doInclude(ServletRequest, ServletResponse) line: 557
        ApplicationDispatcher.include(ServletRequest, ServletResponse) line: 481
        OrbeonXFormsFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 100
        ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 235
        ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206
        ApplicationDispatcher.invoke(ServletRequest, ServletResponse, ApplicationDispatcher$State) line: 654
        ApplicationDispatcher.doInclude(ServletRequest, ServletResponse) line: 557
        ApplicationDispatcher.include(ServletRequest, ServletResponse) line: 481
        PortletRequestDispatcherImpl.include(RenderRequest, RenderResponse) line: 86
        OrbeonViewerPortlet.doView(RenderRequest, RenderResponse) line: 38

// Jonas
Erik Bruchez wrote
Do you know which code actually requires getRequestURL() in this  
particular case?

Issue is that within a portlet, you actually don't know AFAIK the  
request URL (which is an absolute URL starting with http://...).

Just trying here to see if we should return "" or null or something  
else.

-Erik