October 07, 2005 15:54
Programming, Java
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)

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 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}">
    <c:out value="${item.title}"/> <br />    
    <c:out value="${item.body}"/>
  </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 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.

« Eclipse Component Browser | Home | AppFuse Log 3 »

name
url