NPE with <stripes:layout-component> stripes 1.5.7 on Resin 4.0.23

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

NPE with <stripes:layout-component> stripes 1.5.7 on Resin 4.0.23

Stéphane Goetz
Hi,

I'm trying to update from stripes 1.5.1 to 1.5.7 on my projets.

But I'm stuck with a Null Pointer Exception on LayoutComponentTag.java

Just to be precise, all tests were made on Resin 4.0.23.

Here's a test case and what I found out.

test.jsp :
<%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld" %>
<stripes:layout-render name="/layout.jsp">

        <stripes:layout-component name="bodyContent">body
content</stripes:layout-component>

        <stripes:layout-component name="headerContent">header
content</stripes:layout-component>

        <stripes:layout-component name="footerContent">footer
content</stripes:layout-component>

</stripes:layout-render>

layout.jsp :
<%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld" %>
<stripes:layout-definition>
        BEFORE HEADER
        <stripes:layout-component name="headerContent" />
        AFTER HEADER

        BEFORE BODY
        <stripes:layout-component name="bodyContent" />
        AFTER BODY

        BEFORE FOOTER
        <stripes:layout-component name="footerContent" />
        AFTER FOOTER
</stripes:layout-definition>

and I get :
net.sourceforge.stripes.exception.StripesServletException: Unhandled exception
in exception handler.
        at net.sourceforge.stripes.exception.DefaultExceptionHandler.handle(DefaultExceptionHandler.java:179)
        at net.sourceforge.stripes.controller.StripesFilter.doFilter(StripesFilter.java:263)
        ...
Caused by: java.lang.NullPointerException
        at net.sourceforge.stripes.tag.layout.LayoutComponentTag.doStartTag(LayoutComponentTag.java:210)
        at _jsp._test__jsp._jspService(test.jsp:8)
        at _jsp._test__jsp._jspService(_test__jsp.java:29)
        at com.caucho.jsp.JavaPage.service(JavaPage.java:64)
        at com.caucho.jsp.Page.pageservice(Page.java:542)

the cause I found is that "context" in doStartTag is null

Here's a part of the resin compiled JSP

      ...
      _jsp_LayoutComponentTag_1 =
_jsp_state.get_jsp_LayoutComponentTag_1(pageContext, _jsp_parent_tag);
      _jsp_LayoutComponentTag_1.setName("bodyContent");
      int _jspEval7 = _jsp_LayoutComponentTag_1.doStartTag();
      if (_jspEval7 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
        out.write(_jsp_string2, 0, _jsp_string2.length);
      }
      int _jsp_end_8 = _jsp_LayoutComponentTag_1.doEndTag();
      if (_jsp_end_8 == javax.servlet.jsp.tagext.Tag.SKIP_PAGE)
        return;
      out.write(_jsp_string3, 0, _jsp_string3.length);
      _jsp_LayoutComponentTag_1.setName("headerContent");
      int _jspEval11 = _jsp_LayoutComponentTag_1.doStartTag();
      if (_jspEval11 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
        out.write(_jsp_string4, 0, _jsp_string4.length);
      }
      ...

"_jsp_LayoutComponentTag_1" is an instance of LayoutComponentTag and
as we can see, the instance is reused through the different tags
so when it goes through the "doEndTag()" as we see here :
http://stripes.svn.sourceforge.net/viewvc/stripes/trunk/stripes/src/net/sourceforge/stripes/tag/layout/LayoutComponentTag.java?revision=1479&view=markup

it does :
      ...
      finally {
            this.context = null;
            this.silent = false;
            this.componentRenderPhase = null;
      }
      ...

so that explains why the context is null on the second time the
"doStartTag" is called

we also see here :
http://stripes.svn.sourceforge.net/viewvc/stripes/trunk/stripes/src/net/sourceforge/stripes/tag/layout/LayoutComponentTag.java?r1=1465&r2=1479

that "LayoutContext context = getContext();" was removed

my final thought :

is it possible to fix it by adding something like
if(context == null){
      context = LayoutContext.lookup(pageContext);
}

in doStartTag ?

or am I doing something wrong with the layouts (as the layout worked
that way before, I doubt it) ?

Thanks in advance for your answers

---
Stéphane Goetz

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: NPE with <stripes:layout-component> stripes 1.5.7 on Resin 4.0.23

Ben Gunter
I don't have time to look at this right now, but you can get moving forward by switching to the buffered layout tags. Those are the original layout tags under a different URI. See the second bullet in the 1.5.7 release announcement for more info.


-Ben

On Wed, Oct 31, 2012 at 7:19 AM, Stéphane Goetz <[hidden email]> wrote:
Hi,

I'm trying to update from stripes 1.5.1 to 1.5.7 on my projets.

But I'm stuck with a Null Pointer Exception on LayoutComponentTag.java

Just to be precise, all tests were made on Resin 4.0.23.

Here's a test case and what I found out.

test.jsp :
<%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld" %>
<stripes:layout-render name="/layout.jsp">

        <stripes:layout-component name="bodyContent">body
content</stripes:layout-component>

        <stripes:layout-component name="headerContent">header
content</stripes:layout-component>

        <stripes:layout-component name="footerContent">footer
content</stripes:layout-component>

</stripes:layout-render>

layout.jsp :
<%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld" %>
<stripes:layout-definition>
        BEFORE HEADER
        <stripes:layout-component name="headerContent" />
        AFTER HEADER

        BEFORE BODY
        <stripes:layout-component name="bodyContent" />
        AFTER BODY

        BEFORE FOOTER
        <stripes:layout-component name="footerContent" />
        AFTER FOOTER
</stripes:layout-definition>

and I get :
net.sourceforge.stripes.exception.StripesServletException: Unhandled exception
in exception handler.
        at net.sourceforge.stripes.exception.DefaultExceptionHandler.handle(DefaultExceptionHandler.java:179)
        at net.sourceforge.stripes.controller.StripesFilter.doFilter(StripesFilter.java:263)
        ...
Caused by: java.lang.NullPointerException
        at net.sourceforge.stripes.tag.layout.LayoutComponentTag.doStartTag(LayoutComponentTag.java:210)
        at _jsp._test__jsp._jspService(test.jsp:8)
        at _jsp._test__jsp._jspService(_test__jsp.java:29)
        at com.caucho.jsp.JavaPage.service(JavaPage.java:64)
        at com.caucho.jsp.Page.pageservice(Page.java:542)

the cause I found is that "context" in doStartTag is null

Here's a part of the resin compiled JSP

      ...
      _jsp_LayoutComponentTag_1 =
_jsp_state.get_jsp_LayoutComponentTag_1(pageContext, _jsp_parent_tag);
      _jsp_LayoutComponentTag_1.setName("bodyContent");
      int _jspEval7 = _jsp_LayoutComponentTag_1.doStartTag();
      if (_jspEval7 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
        out.write(_jsp_string2, 0, _jsp_string2.length);
      }
      int _jsp_end_8 = _jsp_LayoutComponentTag_1.doEndTag();
      if (_jsp_end_8 == javax.servlet.jsp.tagext.Tag.SKIP_PAGE)
        return;
      out.write(_jsp_string3, 0, _jsp_string3.length);
      _jsp_LayoutComponentTag_1.setName("headerContent");
      int _jspEval11 = _jsp_LayoutComponentTag_1.doStartTag();
      if (_jspEval11 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
        out.write(_jsp_string4, 0, _jsp_string4.length);
      }
      ...

"_jsp_LayoutComponentTag_1" is an instance of LayoutComponentTag and
as we can see, the instance is reused through the different tags
so when it goes through the "doEndTag()" as we see here :
http://stripes.svn.sourceforge.net/viewvc/stripes/trunk/stripes/src/net/sourceforge/stripes/tag/layout/LayoutComponentTag.java?revision=1479&view=markup

it does :
      ...
      finally {
            this.context = null;
            this.silent = false;
            this.componentRenderPhase = null;
      }
      ...

so that explains why the context is null on the second time the
"doStartTag" is called

we also see here :
http://stripes.svn.sourceforge.net/viewvc/stripes/trunk/stripes/src/net/sourceforge/stripes/tag/layout/LayoutComponentTag.java?r1=1465&r2=1479

that "LayoutContext context = getContext();" was removed

my final thought :

is it possible to fix it by adding something like
if(context == null){
      context = LayoutContext.lookup(pageContext);
}

in doStartTag ?

or am I doing something wrong with the layouts (as the layout worked
that way before, I doubt it) ?

Thanks in advance for your answers

---
Stéphane Goetz

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: NPE with <stripes:layout-component> stripes 1.5.7 on Resin 4.0.23

Yttesen
Hi Ben,

I've just upgraded to 1.5.7 and encounters the same issue:

> Caused by: java.lang.NullPointerException
>         at
> net.sourceforge.stripes.tag.layout.LayoutComponentTag.doStartTag(LayoutComponentTag.java:210)

Using the buffered layout tags works as you describe.

Can you please elaborate a bit on whats causing it to fail - I naturally want to use the optimized and preferred tag definition file.

Regards,
Christian