You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Borys Marcelo Borches Herrera (JIRA)" <ji...@apache.org> on 2007/09/05 19:21:34 UTC

[jira] Issue Comment Edited: (WW-1969) Error in TagUtils (NullPointerException) when viewing a page which didn't go through Struts 2 interceptor stack

    [ https://issues.apache.org/struts/browse/WW-1969?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_42144 ] 

borysmarcelo edited comment on WW-1969 at 9/5/07 10:19 AM:
----------------------------------------------------------------------------

I'm having the same problem here. I'm trying to use a simple page as a helloworld to test Struts2 Ajax tag. But, as you can see this issue isn't making it possible. I'm deploying my app into a test Websphere 6.1 TestEnvironment  built in on RAD 7 with Java JRE 5. My Web.xml looks like this:

<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Struts_Course</display-name>

    <filter>
    <filter-name>struts-cleanup</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
</filter>
<filter>
    <filter-name>struts</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>

<filter-mapping>
    <filter-name>struts-cleanup</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>struts</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>


    <listener>
    	<description>
    	</description>
    	<display-name>
    	SpringContextLoader</display-name>
    	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
    	<description>
    	Configures main application</description>
    	<display-name>
    	Configurator</display-name>
    	<servlet-name>Configurator</servlet-name>
    	<servlet-class>
    	com.ibm.learning.struts2.webclient.view.configuration.Configurator</servlet-class>
    	<load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    	<servlet-name>Configurator</servlet-name>
    	<url-pattern>/Configurator</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
    	<welcome-file>welcome.jsp</welcome-file>
    </welcome-file-list>
</web-app>

the welcome page file is set to "welcome.jsp" just as a lot of applications does... but while trying to access the application root http://localhost:9080/Struts_Course/, which it is supposed to forward the request to the welcome.jsp, it gives me a 500 error:

Error 500:


and the following stack trace:

9/5/07 11:52:06:081 BRT] 00000028 ServletWrappe I   SRVE0242I: [Struts_start] [/Struts_Course] [FilterProxyServlet]: Initialization successful.
[9/5/07 11:52:06:352 BRT] 00000028 SystemOut     O 2007-09-05 11:52:06,342 DEBUG (org.apache.struts2.dispatcher.ActionContextCleanUp:122) - skipping cleanup counter=1
[9/5/07 11:52:06:502 BRT] 00000028 ServletWrappe I   SRVE0242I: [Struts_start] [/Struts_Course] [/welcome.jsp]: Initialization successful.
[9/5/07 11:52:06:842 BRT] 00000028 ServletWrappe E   SRVE0068E: Uncaught exception thrown in one of the service methods of the servlet: /welcome.jsp. Exception thrown : java.lang.NullPointerException
	at org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:58)
	at org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:52)
	at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:49)
	at com.ibm._jsp._welcome._jspx_meth_s_head_0(_welcome.java:121)
	at com.ibm._jsp._welcome._jspService(_welcome.java:77)
	at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:989)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:930)
	at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:118)
	at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
	at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:761)
	at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:673)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:498)
	at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
	at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:122)
	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:205)
	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionProcessor.handleRequest(AbstractJSPExtensionProcessor.java:277)
	at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:321)
	at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:555)
	at com.ibm.ws.wswebcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:113)
	at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3252)
	at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:264)
	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
	at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
	at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:112)
	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:454)
	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:383)
	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:263)
	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
	at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
	at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
	at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
	at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
	at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
	at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
	at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469)

here is the welcome.jsp code: 

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<html>
<head>

    <title>Welcome</title>
    <s:head theme="ajax" />
    <link href="<s:url value="/theme/Master.css"/>" rel="stylesheet"
          type="text/css"/>
          
        
          
          
</head>

<s:url id="newUserForm" action="NewUserFormPage" method="generateForm" /> 


<body>


  <script language="Javascript">
          
          function escutaTopico(data, type, e){
            alert('inside a topic event. type='+type + ' data: ' + data);
         //data : text returned
         //type : "before", "load" or "error"
         //e    : request object
         }
          
          dojo.event.topic.subscribe("/after", escutaTopico);
          
          
          
          </script>
<h3>Testing some links to other actions:</h3>
<table>
<tr>
<td>

    <s:a id="registerUserLink" 
     theme="ajax" 
     href="%{newUserForm}" 
     targets="mainContent" notifyTopics="/after" 
     indicator="indicator"> Register</s:a>
     
     <img id="indicator" src="${pageContext.request.contextPath}/pages/images/indicator.gif" alt="Loading..." style="display:none"/>
     
    </td></tr>
    <tr>
    <td>
    
    <div id="mainContent"> Initial content </div>
    
    </td></tr>
    <tr>
    <td>
    <a href="<s:url action="Logon"/>">Sign On</a>
    </td>
    </tr>
</table>
</body>
</html>



So setting issue WW-1969 as an Improvement it's a mistake as most applications have calls directly jsp's without going through Struts actions.

      was (Author: borysmarcelo):
    I'm having the same problem here. I'm trying to use a simple page as a helloworld to test Struts2 Ajax tag. But, as you can see this issue isn't making it possible. I'm deploying my app into a test Websphere 6.1 TestEnvironment  built in on RAD 7. My Web.xml looks like this:

<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Struts_Course</display-name>

    <filter>
    <filter-name>struts-cleanup</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
</filter>
<filter>
    <filter-name>struts</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>

<filter-mapping>
    <filter-name>struts-cleanup</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>struts</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>


    <listener>
    	<description>
    	</description>
    	<display-name>
    	SpringContextLoader</display-name>
    	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
    	<description>
    	Configures main application</description>
    	<display-name>
    	Configurator</display-name>
    	<servlet-name>Configurator</servlet-name>
    	<servlet-class>
    	com.ibm.learning.struts2.webclient.view.configuration.Configurator</servlet-class>
    	<load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    	<servlet-name>Configurator</servlet-name>
    	<url-pattern>/Configurator</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
    	<welcome-file>welcome.jsp</welcome-file>
    </welcome-file-list>
</web-app>

the welcome page file is set to "welcome.jsp" just as a lot of applications does... but while trying to access the application root http://localhost:9080/Struts_Course/, which it is supposed to forward the request to the welcome.jsp, it gives me a 500 error:

Error 500:


and the following stack trace:

9/5/07 11:52:06:081 BRT] 00000028 ServletWrappe I   SRVE0242I: [Struts_start] [/Struts_Course] [FilterProxyServlet]: Initialization successful.
[9/5/07 11:52:06:352 BRT] 00000028 SystemOut     O 2007-09-05 11:52:06,342 DEBUG (org.apache.struts2.dispatcher.ActionContextCleanUp:122) - skipping cleanup counter=1
[9/5/07 11:52:06:502 BRT] 00000028 ServletWrappe I   SRVE0242I: [Struts_start] [/Struts_Course] [/welcome.jsp]: Initialization successful.
[9/5/07 11:52:06:842 BRT] 00000028 ServletWrappe E   SRVE0068E: Uncaught exception thrown in one of the service methods of the servlet: /welcome.jsp. Exception thrown : java.lang.NullPointerException
	at org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:58)
	at org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:52)
	at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:49)
	at com.ibm._jsp._welcome._jspx_meth_s_head_0(_welcome.java:121)
	at com.ibm._jsp._welcome._jspService(_welcome.java:77)
	at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:989)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:930)
	at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:118)
	at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
	at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:761)
	at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:673)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:498)
	at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
	at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:122)
	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:205)
	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionProcessor.handleRequest(AbstractJSPExtensionProcessor.java:277)
	at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:321)
	at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:555)
	at com.ibm.ws.wswebcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:113)
	at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3252)
	at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:264)
	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
	at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
	at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:112)
	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:454)
	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:383)
	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:263)
	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
	at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
	at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
	at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
	at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
	at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
	at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
	at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469)

here is the welcome.jsp code: 

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<html>
<head>

    <title>Welcome</title>
    <s:head theme="ajax" />
    <link href="<s:url value="/theme/Master.css"/>" rel="stylesheet"
          type="text/css"/>
          
        
          
          
</head>

<s:url id="newUserForm" action="NewUserFormPage" method="generateForm" /> 


<body>


  <script language="Javascript">
          
          function escutaTopico(data, type, e){
            alert('inside a topic event. type='+type + ' data: ' + data);
         //data : text returned
         //type : "before", "load" or "error"
         //e    : request object
         }
          
          dojo.event.topic.subscribe("/after", escutaTopico);
          
          
          
          </script>
<h3>Testing some links to other actions:</h3>
<table>
<tr>
<td>

    <s:a id="registerUserLink" 
     theme="ajax" 
     href="%{newUserForm}" 
     targets="mainContent" notifyTopics="/after" 
     indicator="indicator"> Register</s:a>
     
     <img id="indicator" src="${pageContext.request.contextPath}/pages/images/indicator.gif" alt="Loading..." style="display:none"/>
     
    </td></tr>
    <tr>
    <td>
    
    <div id="mainContent"> Initial content </div>
    
    </td></tr>
    <tr>
    <td>
    <a href="<s:url action="Logon"/>">Sign On</a>
    </td>
    </tr>
</table>
</body>
</html>



So setting issue WW-1969 as an Improvement it's a mistake as most applications have calls directly jsp's without going through Struts actions.
  
> Error in TagUtils (NullPointerException) when viewing a page which didn't go through Struts 2 interceptor stack
> ---------------------------------------------------------------------------------------------------------------
>
>                 Key: WW-1969
>                 URL: https://issues.apache.org/struts/browse/WW-1969
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Views
>    Affects Versions: 2.0.6
>         Environment: Tomcat 4.1
> Java 1.4
> Struts 2 - Java 1.4 retrotranslated version
>            Reporter: Cyril Gambis
>            Priority: Critical
>             Fix For: Future
>
>
> I searched for that item and havn't find anything in JIRA. I think there may be a patch because it is quite a serious issue and it is a regression from Struts 2.0.5 as I read on some forum.
> With this bug, some HelloWorld tutorials don't work anymore.
> The stack trace is:
> Stacktrace:
> org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrappe r.java:467)
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389)
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> root cause
> java.lang.NullPointerException
> org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:58)
> org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport .java:54)
> org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport .java:49)
> org.apache.jsp.WebContent.index_jsp._jspx_meth_s_005fhead_005f0(index_jsp.java: 155)
> org.apache.jsp.WebContent.index_jsp._jspService(index_jsp.java:77)
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 
> I understand that if you access directly a jsp page containing a tag like s:text, s:a or s:url, which usually won't need for a value stack. A solution may be to have everything go through the struts 2 interceptor stack, but believe me, for legacy application it is sometimes not easy at all (one of my developer has work on this problem for 2 days, currently).
> Is there any patch, anywhere? Especially for the Java 1.4 version or Struts 2?
> Some links:
> http://forums.opensymphony.com/thread.jspa?messageID=155149&#155149
> http://www.mail-archive.com/user@struts.apache.org/msg57582.html
> Thanks!
> Cyril Gambis

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.