users@glassfish.java.net

RE: Random NullPointerExceptions from ValueExpression

From: Romanowski, Tim <tim.romanowski_at_lmco.com>
Date: Thu, 16 Aug 2007 17:35:51 -0400

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(CoyoteRequestFaca
de.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(FacesCompositeELResol
ver.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)

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 5th 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