Hi Tim,
Romanowski, Tim wrote:
> I’m encountering a similar problem with a JSF application I am trying
> to run on Glassfish. Someone else posted a similar problem to the
> Tomcat users mailing list a couple years ago, but they never got a
> response [1].
>
> [1]
> http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg145545.html
>
> Setup:
>
> Glassfish V2 Build 58
>
> Java 1.5.0_12-b04
>
> java.lang.NullPointerException
>
> at
> org.apache.coyote.tomcat5.CoyoteRequest.setAttribute(CoyoteRequest.java:1730)
>
> at
> org.apache.coyote.tomcat5.CoyoteRequestFacade.setAttribute(CoyoteRequestFacade.java:540)
>
> at
> javax.servlet.ServletRequestWrapper.setAttribute(ServletRequestWrapper.java:308)
>
> at com.sun.faces.context.RequestMap.put(ExternalContextImpl.java:1069)
>
> at
> com.sun.faces.el.FacesCompositeELResolver.setChainType(FacesCompositeELResolver.java:153)
>
> at
> com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:63)
>
> at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:86)
>
> at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:206)
>
It looks like someone (com.sun.faces.context.RequestMap?) is holding on
to the
request object after it has been processed, and calls setAttribute() on it.
Notice that after a request has been processed, it is recycled,
and its "context" instance variable is set to null, which would cause
the NPE at line 1730 in CoyoteRequest.java during the invocation of
setAttribute().
Can you reproduce the error pretty consistently? I understand
that the original reporter (who reported the issue against Tomcat)
could not.
Thanks!
Jan
> Any suggestions on how to resolve this would be greatly appreciated!
>
> Tim
>
> ------------------------------------------------------------------------
>
> *From:* Woods, Michael G
> *Sent:* Thursday, August 16, 2007 12:01 PM
> *To:* users_at_glassfish.dev.java.net
> *Subject:* Random NullPointerExceptions from ValueExpression
>
> I have a problem grabbing “TaskController” from my application. Upon
> logging into the web app and requesting the servlet that the following
> code is running, I randomly get the proper output or a
> NullPointerException. The exception occurs in the 5^th line of code
> listed below:
>
> FacesContext fc = FacesContext.getCurrentInstance();
>
> Application app = fc.getApplication();
>
> ExpressionFactory expFactory = app.getExpressionFactory();
>
> ValueExpression valExp =
> expFactory.createValueExpression(fc.getELContext(),
> "#{taskController}", TaskController.class);
>
> TaskController tc = (TaskController) valExp.getValue(fc.getELContext());
>
> tc is null after this, however if I request the link again and again,
> I’ll get proper output about once every five requests (the very first
> request is always correct).
>
> I’ve also tried the deprecated ValueBinding method however that
> results in the same situation. Anyone have a suggestion on where to
> look for the cause of this problem?
>
> Thanks,
>
> Mike Woods
>