AppFuse Log 4

Posted by wsargent Fri, 07 Oct 2005 20:54:00 GMT

I ran through the example that I made in the previous post.

java.lang.NullPointerException

at com.opensymphony.webwork.views.jsp.ActionTag.executeAction(ActionTag.java:186)
at com.opensymphony.webwork.views.jsp.ActionTag.doEndTag(ActionTag.java:85)
at /index.jsp._jspService(/index.jsp.java:38)</pre></div>

Looked up the WebWork 2.1.7 source code. The stacktrace (using 2.1.6 )didn’t match up with the source, so it was a fair bet that the libraries had changed. Copied over the webwork library, changed the references, and got an error page with nothing in the log.

However, at this point I’d bought a clue and started wrapping my code in <c:catch var=”error”> tags. The page exception complained about OGNL missing a method. Copied over the OGNL and xWork libraries. Tried it again, and it worked.

So what I’m doing now isn’t great, but it gets data out:

<c:catch var="exception"> 
<%-- Call the display posts action and expose it to JSTL as postz --%> <ww:action name="'displayPosts'" id="displayPostsObj" /> <ww:set name="postz" value="#displayPostsObj.posts" scope="page"/>

<c:forEach var="item" items="${postz}">

&lt;c:out value="${item.title}"/&gt; &lt;br /&gt;    
&lt;c:out value="${item.body}"/&gt;

</c:forEach> </c:catch>

<c:if test=”${exception != null}”> An error occurred <c:out value=”${exception.message}”/><br> Error is of type <c:out value=”${exception.class}”/><br> Stacktrace: <br> <pre> <%
Throwable t = (Throwable)pageContext.getAttribute(“exception”); t.printStackTrace(new java.io.PrintWriter(out)); %> </c:if>

with the code being:

public List getPosts()
{

PostManager postManager = getPostManager();
List<Post> posts;
try
{
    posts = postManager.getPosts();
    if (isLoggingDebug())
    {
        String msg = "getPosts: posts = " + posts;
        logDebug(msg);
    }

    return posts;
} catch (DAOException e)
{
    if (isLoggingError())
    {
        String msg = "Cannot get posts: ";
        logError(msg, e);
    }
}

return Collections.emptyList();

}

Where the postManager is set through Spring. And yes, it does actually show hibernate output and iterate correctly.

Now it’s display, filter and sort time.

Leave a comment

Comments