Stripes

Relative path for layout-render tag's name attrib causes exception

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Duplicate
  • Affects Version/s: Release 1.5
  • Fix Version/s: Release 1.5.1, Release 1.6
  • Component/s: Tag Library
  • Labels:
    None
  • Environment:
    Stripes 1.5, JDK1.5.0_13, Tomcat 6.0, Eclipse 3.4.1

Description

There seems to be a problem in the layout-render taglib wrt the use of relative paths.

I have found 1 other JIRA issue about this, but I don't think it described the issue properly. http://www.stripesframework.org/jira/browse/STS-591

Also see relating issue on Nabble: http://www.nabble.com/Problem-with-NullPointerException-using-layouts-td20285899.html#a20285899

Scenario 1:
Example:
<stripes:layout-render name="../layout/defaultlayout.jsp">
...........
</stripes:layout-render>

Causes an exception:
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at net.sourceforge.stripes.tag.layout.LayoutDefinitionTag.doStartTag(LayoutDefinitionTag.java:72)
at org.apache.jsp.WEB_002dINF.jsp.layout.defaultlayout_jsp._jspx_meth_stripes_005flayout_002ddefinition_005f0(defaultlayout_jsp.java:87)
at org.apache.jsp.WEB_002dINF.jsp.layout.defaultlayout_jsp._jspService(defaultlayout_jsp.java:63)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
...........
06:57:30,625 WARN DefaultExceptionHandler:90 - Unhandled exception caught by the Stripes default exception handler.
org.apache.jasper.JasperException: javax.servlet.ServletException: net.sourceforge.stripes.exception.StripesJspException: An exception was raised while invoking a layout. The layout used was '../layout/defaultlayout.jsp'. The following information was supplied to the render tag: LayoutContext{component names=[contents], parameters={}}
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
...........
Caused by: javax.servlet.ServletException: net.sourceforge.stripes.exception.StripesJspException: An exception was raised while invoking a layout. The layout used was '../layout/defaultlayout.jsp'. The following information was supplied to the render tag: LayoutContext{component names=[contents], parameters={}}
at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
at org.apache.jsp.WEB_002dINF.jsp.secure.home_jsp._jspService(home_jsp.java:71)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
... 69 more
Caused by: org.apache.jasper.JasperException: java.lang.NullPointerException
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at net.sourceforge.stripes.controller.DynamicMappingFilter.doFilter(DynamicMappingFilter.java:345)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:535)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:472)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
at org.apache.jasper.runtime.PageContextImpl.doInclude(PageContextImpl.java:640)
at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:634)
at net.sourceforge.stripes.tag.layout.LayoutRenderTag.doEndTag(LayoutRenderTag.java:113)
at org.apache.jsp.WEB_002dINF.jsp.secure.home_jsp._jspx_meth_stripes_005flayout_002drender_005f0(home_jsp.java:110)
at org.apache.jsp.WEB_002dINF.jsp.secure.home_jsp._jspService(home_jsp.java:62)
... 72 more
Caused by: java.lang.NullPointerException
at net.sourceforge.stripes.tag.layout.LayoutDefinitionTag.doStartTag(LayoutDefinitionTag.java:72)
at org.apache.jsp.WEB_002dINF.jsp.layout.defaultlayout_jsp._jspx_meth_stripes_005flayout_002ddefinition_005f0(defaultlayout_jsp.java:87)
at org.apache.jsp.WEB_002dINF.jsp.layout.defaultlayout_jsp._jspService(defaultlayout_jsp.java:63)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
... 89 more

This issue occurs if running via Eclipse or straight on Tomcat. Cleaning build and Tomcat cache has no effect.

Scenario 2:
Changing overriding JSP to use absolute path:
<stripes:layout-render name="/WEB-INF/jsp/layout/defaultlayout.jsp">
...........
</stripes:layout-render>

Solves the problem.

Placing a breakpoint on net.sourceforge.stripes.tag.layout.LayoutDefinitionTag (line 70 - Stripes 1.5), will show that once you step over 70 & 71, that the stack variable is NULL in scenario 1, but is correctly created in scenario 2.

LayoutDefinitionTag:
69: // Fetch the layout context containing parameters and component overrides
70: Stack<LayoutContext> stack = (Stack<LayoutContext>)
71: getPageContext().getRequest().getAttribute(PREFIX + name);
72 this.context = stack.peek();

Evaluating the expression (PREFIX + name) in scenario 1 gives you:
stripes.layout./WEB-INF/jsp/layout/defaultlayout.jsp

Evaluating the expression (PREFIX + name) in scenario 2 also gives you:
stripes.layout./WEB-INF/jsp/layout/defaultlayout.jsp

Quite strange. The problem must be deeper...

  1. defaultlayout.jsp
    20/Jan/09 11:23 PM
    0.6 kB
    Rudolf Ingerl
  2. home.jsp
    20/Jan/09 11:24 PM
    0.3 kB
    Rudolf Ingerl

Activity

Hide
Rudolf Ingerl added a comment - 20/Jan/09 11:23 PM

Place in: \WEB-INF\jsp\layout\

Show
Rudolf Ingerl added a comment - 20/Jan/09 11:23 PM Place in: \WEB-INF\jsp\layout\
Hide
Rudolf Ingerl added a comment - 20/Jan/09 11:24 PM

Place in: \WEB-INF\jsp\secure\

Show
Rudolf Ingerl added a comment - 20/Jan/09 11:24 PM Place in: \WEB-INF\jsp\secure\
Hide
Frederic Daoud added a comment - 21/Jan/09 8:47 AM

Actually, STS-591 accurately describes the problem: relative paths do not work with layouts, and if they do, it's by coincidence and very fragile. I'll add a warning about this so that you get an error message describing the problem if you use a relative path in a layout-render tag.

Show
Frederic Daoud added a comment - 21/Jan/09 8:47 AM Actually, STS-591 accurately describes the problem: relative paths do not work with layouts, and if they do, it's by coincidence and very fragile. I'll add a warning about this so that you get an error message describing the problem if you use a relative path in a layout-render tag.
Hide
Rudolf Ingerl added a comment - 23/Jan/09 2:15 AM

Hi Frederic

Thanks for the feedback.

I'm sure a warning would help other developers who might step into this one...

Thanks!

Show
Rudolf Ingerl added a comment - 23/Jan/09 2:15 AM Hi Frederic Thanks for the feedback. I'm sure a warning would help other developers who might step into this one... Thanks!

People

Vote (0)
Watch (1)

Dates

  • Created:
    20/Jan/09 11:22 PM
    Updated:
    23/Jan/09 2:15 AM
    Resolved:
    21/Jan/09 8:47 AM