1

I have a JSP, which calls an action using the <s:action> tag:

<s:form>
    <s:action name="myaction"
        namespace="/utente/include" executeResult="true"
        ignoreContextParams="true" var="formattazione" />
    
    //do something
</s:form>

The action myaction is called, i can follow the flow debugging it. It finishes fine without error, it returns success, but then there is an error and i can't understand which one.

The action definition:

<package name="utente-include" namespace="/utente/include" extends="tiles-default">
    
    <action name="myaction" class="com.emaborsa.doctracing.web.action.formattazione.FormattazioneCriteriUtenteAction"
        method="formattazione">
        <result type="tiles">mytiles.def</result>
    </action>
    
</package>

The tiles definition:

<definition name="mytiles.def" template="/pages/empty.jsp">
    <put-attribute name="body" value="/pages/mypage.jsp"/>
</definition>

The empty.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<tiles:insertAttribute name="body" />

The Exception:

GRAVE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:49)
at org.apache.jsp.pages.utente.elencoUtenti_jsp._jspx_meth_s_005fif_005f0(elencoUtenti_jsp.java:215)
at org.apache.jsp.pages.utente.elencoUtenti_jsp._jspx_meth_s_005fform_005f0(elencoUtenti_jsp.java:155)
at org.apache.jsp.pages.utente.elencoUtenti_jsp._jspService(elencoUtenti_jsp.java:87)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
.....

EDIT:

I thought it works, but it doesn't. Actually the system doesn't crash, but the tiles-page is not included in the mail page. The Exception i get:

org.apache.tiles.impl.CannotRenderException: No request dispatcher returned for path '/../pages/common/myPage.jsp'
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:680)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:633)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:322)
at org.apache.struts2.views.tiles.TilesResult.doExecute(TilesResult.java:105)
at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:361)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:265)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)

Here my myPage.jsp (actually it doesn't matter what is written in):

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

<div class="navigazioneElenco" id="navigazioneElenco">

</div>

Here I share a part of my project. There is only the part which is not working... DOWNLOAD

Roman C
  • 49,761
  • 33
  • 66
  • 176
Emaborsa
  • 2,360
  • 4
  • 28
  • 50
  • [Take a look at this, it *may* help...](https://issues.apache.org/jira/browse/WW-2995?focusedCommentId=12824702&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12824702) – Andrea Ligios Oct 01 '13 at 16:41
  • If you are using Struts2-Tiles3, take a look at this: http://stackoverflow.com/a/14540358/1654265 – Andrea Ligios Oct 02 '13 at 08:42
  • It's not a problem of lists or somthing similar. The myPage is never loaded, i've tried also to pass a jsp with only a text string and i get the same error. It seems that struts doesn't recognize the tiles definition... – Emaborsa Oct 02 '13 at 08:51
  • try with `` . If it doesn't work, post more information: version of Struts, version of Tiles, directories structure, etc – Andrea Ligios Oct 02 '13 at 09:05
  • Post your web.xml and url used to call action - NPE there means Dispatcher wasn't initialised – Lukasz Lenart Oct 03 '13 at 14:21
  • I did some experiments. I've seen that if i'm using jsp prefixed tags `` and struts prefixed tags `` in the same JSP, it crashes. If i remove one of these, it doens't throw Exceptions. Is it ok or is it a bug? – Emaborsa Oct 03 '13 at 14:36
  • ...i was not able to make it run. I get an exception and on the web i can't find any help. I get `org.apache.tiles.impl.CannotRenderException: No request dispatcher returned for path '/../pages/common/mzPage.jsp'` – Emaborsa Oct 07 '13 at 14:47
  • Show your `mypage.jsp`. Which version of Struts2 and Tiles? – Aleksandr M Oct 07 '13 at 17:17
  • Struts is version 2.1.6 and Tiles 2.1.2 – Emaborsa Oct 07 '13 at 18:12
  • I found out the problem. It's not a tiles or struts component that bothers...again it complains if i use an `` tag and other struts tags in the same jsp. If i use only this ` it works. – Emaborsa Oct 08 '13 at 06:48
  • I added the link to download my project...please take a look. – Emaborsa Oct 15 '13 at 07:09

2 Answers2

0

May this error comes from your jsp page. Can you post the code available in mypage.jsp? Or check manually did u using any scriptlet tags may cause the null pointer exception. Check the values by using struts logic tags. So you might not come across null pointer exception.

Vinoth Krishnan
  • 2,925
  • 6
  • 29
  • 34
  • Well, i tries to pass other jsp pages, which on a usual call they work, but in this case they doesn't work. I also tries to call this action (myaction) directly from the URL, and the result is displayed...so the problem must be in the struts/tiles definition (i guess) – Emaborsa Oct 02 '13 at 06:10
0

Solved updating to Struts 2.3.15.2

Emaborsa
  • 2,360
  • 4
  • 28
  • 50