timp/atombeat

null pointer exception during internal request call to request:set-attribute

Closed this issue · 3 comments

What steps will reproduce the problem?

It's hard to reproduce this with a single request, but a particular sequence of 
several requests where the requests have side-effects involving calling 
internal requests via the plugin-util module will fairly reliably expose this 
issue.

The exception occurs during an attempt by a plugin function to call 
request:set-attribute (the conneg plugin in this case), but it appears that 
there is some problem accessing the request context.

See comments for the stack trace.

Original issue reported on code.google.com by alimanfoo@googlemail.com on 25 Feb 2011 at 8:18

Some logging and the exception stack trace:

25 Feb 2011 08:14:13,760 [http-8080-1] INFO  (LogFunction.java [eval]:141) - 
(Line: 26) conneg-plugin - before: CREATE_COLLECTION, request-path-info: 
/asset/project/36etce 
25 Feb 2011 08:14:13,761 [http-8080-1] DEBUG (LogFunction.java [eval]:145) - 
(Line: 57) preparing for conneg 
25 Feb 2011 08:14:13,762 [http-8080-1] DEBUG (LogFunction.java [eval]:145) - 
(Line: 436) application/atom+xml 
25 Feb 2011 08:14:13,764 [http-8080-1] DEBUG (LogFunction.java [eval]:145) - 
(Line: 468) <accept>
    <media-range>application/atom+xml</media-range>
    <quality>1</quality>
</accept> 
25 Feb 2011 08:14:13,765 [http-8080-1] DEBUG (LogFunction.java [eval]:145) - 
(Line: 481) <variant>
    <output-key>atom</output-key>
    <media-type>application/atom+xml</media-type>
    <output-type>xml</output-type>
    <qs>0.8</qs>
</variant> 
25 Feb 2011 08:14:13,766 [http-8080-1] DEBUG (LogFunction.java [eval]:145) - 
(Line: 501) 0.8 
25 Feb 2011 08:14:13,767 [http-8080-1] DEBUG (LogFunction.java [eval]:145) - 
(Line: 505) 0.8 
25 Feb 2011 08:14:13,768 [http-8080-1] DEBUG (LogFunction.java [eval]:145) - 
(Line: 509) 1 
25 Feb 2011 08:14:13,769 [http-8080-1] DEBUG (LogFunction.java [eval]:145) - 
(Line: 515) 1 
25 Feb 2011 08:14:13,770 [http-8080-1] DEBUG (LogFunction.java [eval]:145) - 
(Line: 519) <variant>
    <output-key>atom</output-key>
    <media-type>application/atom+xml</media-type>
    <output-type>xml</output-type>
    <qs>0.8</qs>
</variant> 
25 Feb 2011 08:14:13,771 [http-8080-1] DEBUG (LogFunction.java [eval]:145) - 
(Line: 72) output key: atom 
25 Feb 2011 08:14:13,772 [http-8080-1] DEBUG (LogFunction.java [eval]:145) - 
(Line: 77) storing output key as request attribute: 
atombeat.conneg.output-key.CREATE_COLLECTION./asset/project/36etce 
25 Feb 2011 08:14:13,774 [http-8080-1] DEBUG (CatchFunction.java [eval]:89) - 
Caught exception in util:catch: null 
25 Feb 2011 08:14:13,774 [http-8080-1] WARN  (CatchFunction.java [eval]:91) - 
Exception: null 
java.lang.NullPointerException
    at org.apache.catalina.connector.Request.setAttribute(Request.java:1423)
    at org.apache.catalina.connector.RequestFacade.setAttribute(RequestFacade.java:503)
    at javax.servlet.ServletRequestWrapper.setAttribute(ServletRequestWrapper.java:284)
    at javax.servlet.ServletRequestWrapper.setAttribute(ServletRequestWrapper.java:284)
    at javax.servlet.ServletRequestWrapper.setAttribute(ServletRequestWrapper.java:284)
    at javax.servlet.ServletRequestWrapper.setAttribute(ServletRequestWrapper.java:284)
    at javax.servlet.ServletRequestWrapper.setAttribute(ServletRequestWrapper.java:284)
    at org.exist.http.servlets.HttpRequestWrapper.setAttribute(HttpRequestWrapper.java:608)
    at org.exist.xquery.functions.request.SetAttribute.eval(SetAttribute.java:104)
    at org.exist.xquery.InternalFunctionCall.eval(InternalFunctionCall.java:55)
    at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:61)
    at org.exist.xquery.PathExpr.eval(PathExpr.java:241)
    at org.exist.xquery.ConditionalExpression.eval(ConditionalExpression.java:100)
    at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:61)
    at org.exist.xquery.PathExpr.eval(PathExpr.java:241)
    at org.exist.xquery.LetExpr.eval(LetExpr.java:155)
    at org.exist.xquery.LetExpr.eval(LetExpr.java:206)
    at org.exist.xquery.LetExpr.eval(LetExpr.java:206)

Original comment by alimanfoo@googlemail.com on 25 Feb 2011 at 8:19

I found a couple of links suggesting this is due to the request object being 
accessed from an inappropriate context:

http://mail-archives.apache.org/mod_mbox/tomcat-users/201008.mbox/%3C13691_12810
18206_o75ENIW3018250_4C5AC935.6000206@rackspace.com%3E

http://ocpsoft.com/java/jsf-java/please-tell-your-developers-to-call-facescontex
trelease

http://old.nabble.com/NullPointerException-5.5.17-Request.setAttribute(Request.j
ava:1376)-td19044794.html

Original comment by alimanfoo@googlemail.com on 25 Feb 2011 at 8:21

fixed in revision 616

Original comment by alimanfoo@googlemail.com on 25 Feb 2011 at 11:46

  • Changed state: Fixed