users@glassfish.java.net

Glassfish Communication: NullPointerException at setAttribute

From: <glassfish_at_javadesktop.org>
Date: Tue, 21 Jul 2009 20:13:49 PDT

Hi, hope anyone has an idea to fix this problem. Not sure yet if it's a server issue or a servlet flow issue.

Here's the scenario...

I created an initial SIP REGISTER request using an HttpServlet and set the session handler that would handle the proxy's responses. In my initial request, I passed the HttpServletRequest object as an attribute for the SipServletRequest, so that I can access later on the setAttribute of the HttpServlet.

sipRequest.setAttribute("httpRequest", (HttpServletRequest) request);
sipRequest.getSession().setHandler("register");

request.getRequestDispatcher("processing.jsp").forward(request, response);

Noticed that I forwarded a temporary page while waiting for the Handler's task to be done. This processing.jsp will refresh every 4 seconds until the value of request.getAttribute("result") becomes not null. We set the value of "result" inside the handler where we passed the HttpServletRequest object.

Inside the handler is an override method doSuccessResponse which contains this code:

HttpServletRequest httpRequest = (HttpServletRequest) response.getRequest.getAttribute("httpRequest");
httpRequest.setAttribute("result", "SUCCESS");

We expect in the first loading of processing.jsp that the value of request "result" attribute is null but after the refreshing of JSP page (<meta equiv="refresh" content="4">) and processing of SIP REGISTER in Session handler it becomes not null.

This works fine without error and sometimes not. Frequently, after one to two tries of logging, it runs well, yet at the succeeding tries, an error occurs at line where I do the setAttribute. I've check if the value of HttpServletRequest object is null, yet it is NOT NULL. Also I am passing a string "SUCCESS" so that shouldn't be null. And besides, it works at first and second tries, how come it will not work on the other succeeding tries. So I guess it's either a server issue or an issue about the flow of my data.

Additional Info:
IDE: Eclipse Ganymede 3.4.2
Server: Glassfish Communications Server
API: SipServlet-v1.1

Here's the Exception details:

INFO: LOGIN RESULT: SUCCESSFUL REQUEST
WARNING: HAS ERROR:null
WARNING: java.lang.NullPointerException
        at org.apache.coyote.tomcat5.CoyoteRequest.setAttribute(CoyoteRequest.java:1806)
        at org.apache.coyote.tomcat5.CoyoteRequestFacade.setAttribute(CoyoteRequestFacade.java:581)
        at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:344)
        at com.websip.module.security.UserAuthenticationSipServlet.doSuccessResponse(UserAuthenticationSipServlet.java:153)
        at javax.servlet.sip.SipServlet.doResponse(SipServlet.java:180)
        at javax.servlet.sip.SipServlet.service(SipServlet.java:48)
        at com.ericsson.ssa.container.sim.SipServletFacade.service(SipServletFacade.java:91)
        at com.ericsson.ssa.sip.GeneralSession.dispatch(GeneralSession.java:224)
        at com.ericsson.ssa.sip.UA.dispatch(UA.java:706)
        at com.ericsson.ssa.container.sim.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:764)
        at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:70)
        at com.ericsson.ssa.container.sim.ApplicationDispatcher.next(ApplicationDispatcher.java:884)
        at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:77)
        at com.ericsson.ssa.sip.LocalRouteManager.next(LocalRouteManager.java:106)
        at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:77)
        at com.ericsson.ssa.sip.DialogManager.next(DialogManager.java:704)
        at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:77)
        at com.ericsson.ssa.sip.dns.ResolverManager.next(ResolverManager.java:195)
        at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:77)
        at com.ericsson.ssa.sip.persistence.ReplicationManager.next(ReplicationManager.java:124)
        at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:77)
        at com.ericsson.ssa.sip.transaction.TransactionManager.next(TransactionManager.java:351)
        at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:77)
        at com.ericsson.ssa.container.OutboundFlowManager.next(OutboundFlowManager.java:231)
        at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:77)
[Message sent by forum member 'naselay' (naselay)]

http://forums.java.net/jive/thread.jspa?messageID=356891