So, so far, I've set up one web application, StyleApp, with a
layout.jsp file, and another web application which consumes that
layout.jsp with sitemesh 2.4.2. The consumer's decorator file looks
like:
<?xml version="1.0" encoding="ISO-8859-1"?>
<decorators >
<decorator name="layout" page="/decorators/layout.jsp"
webapp="StyleApp">
<pattern>/*</pattern>
</decorator>
</decorators>
I should note as well that we use WebSphere Application Server 6.1
here, and the applications are deployed in separate wars in separate
ears.
When I bring up the consumer page in the web browser I get the
following exception:
[3/30/12 15:22:30:174 CDT] 00000021 ServletWrappe I SRVE0253I:
[DefaultEARNonSecure] [/StyleApp] [/decorators/layout.jsp]: Destroy
successful.
[3/30/12 15:22:30:212 CDT] 00000021 ServletWrappe I SRVE0242I:
[DefaultEARNonSecure] [/StyleApp] [/decorators/layout.jsp]:
Initialization successful.
[3/30/12 15:22:30:219 CDT] 00000021 SystemErr R
[3/30/12 15:22:30:219 CDT] 00000021 SystemErr R at
com.opensymphony.module.sitemesh.taglib.AbstractTag.getPage(AbstractTag.java:
64)
[3/30/12 15:22:30:219 CDT] 00000021 SystemErr R at
com.opensymphony.module.sitemesh.taglib.decorator.BodyTag.doEndTag(BodyTag.java:
26)
[3/30/12 15:22:30:219 CDT] 00000021 SystemErr R at
com.ibm._jsp._layout._jspx_meth_decorator_body_0(_layout.java:150)
I downloaded the source code for 2.4.2 from
https://java.net/downloads/sitemesh/SiteMesh%202.4.2/
and have been stepping through what happens in the IDE. The exception
occurs here:
com.opensymphony.module.sitemesh.Page.AbstractTag:
protected Page getPage() {
Page p = (Page)pageContext.getAttribute(PAGE,
PageContext.PAGE_SCOPE);
// ^^^ HERE at this cast
if (p == null) {
p = (Page)pageContext.getAttribute(PAGE,
PageContext.REQUEST_SCOPE);
if (p == null) {
pageContext.removeAttribute(PAGE,
PageContext.PAGE_SCOPE);
}
else {
pageContext.setAttribute(PAGE, p,
PageContext.PAGE_SCOPE);
}
pageContext.removeAttribute(PAGE,
PageContext.REQUEST_SCOPE);
}
return p;
}
The PAGE attribute is set earlier here:
com.opensymphony.sitemesh.compatability.OldDecorator2NewDecorator
protected void render(Content content, HttpServletRequest request,
HttpServletResponse response,
ServletContext servletContext,
SiteMeshWebAppContext webAppContext)
throws IOException, ServletException {
request.setAttribute(PAGE, new Content2HTMLPage(content,
request));
// ^^^^ HERE
// see if the URI path (webapp) is set
if (oldDecorator.getURIPath() != null) {
// in a security conscious environment, the servlet
container
// may return null for a given URL
if (servletContext.getContext(oldDecorator.getURIPath()) !
= null) {
servletContext =
servletContext.getContext(oldDecorator.getURIPath());
}
}
// get the dispatcher for the decorator
RequestDispatcher dispatcher =
servletContext.getRequestDispatcher(oldDecorator.getPage());
dispatcher.include(request, response);
^^^^^ include calls the code that eventually calls the
exception code
request.removeAttribute(PAGE);
}
In the comments for this file (OldDecorator2NewDecorator.java) it says
that this class "Adapts a SiteMesh 2 {@link
com.opensymphony.module.sitemesh.Decorator} to a SiteMesh 3 {@link
com.opensymphony.sitemesh.Decorator}." I thought that maybe some new
code had been incorporated, for SiteMesh 3 that had broken it, but I
tried rolling back the library to SiteMesh 2.3 and I got a slightly
different error with a different class name in the same place. (I
neglected to copy the message)
Does anyone have any suggestions about what I could try next? I'm
very interested in this feature, as I like SiteMesh and the ability to
use a single layout from multiple wars would be a big help in our
organization.