Jeroen, I would put a try catch block around the getBlogItem method: public Iterator getBlogItem() { try { Session session = HibernateUtil.currentSession(); Transaction tx = session.beginTransaction();
Query query = session.createQuery("select b from BlogItem as b"); blogItem = query.iterate(); tx.commit(); HibernateUtil.closeSession(); return blogItem; } } catch (Throwable t){ System.out.println("Error in getBlogItem: "+t); t.printStackTrace(); throw new Error("check your logs for errors"); // so it exits the method as it should } } Regards, Jacob -----Original Message----- From: Jeroen P [mailto:[EMAIL PROTECTED] Sent: vrijdag 24 juni 2005 11:28 To: Struts-User Subject: How to find the cause of the error Hi, I've got a prolbem with finding the error in my code. I'm trying to integrate Hibernate in my application. Tomcat gives a stack trace, but it didn't give a line number where the error occurred. It looks like it goes wrong with the logic:iterator in my JSP page and the BlogItem getter in BlogBean. I'm using Netbeans 4.1 as my IDE. Does anybody know how I can find where it goes wrong ? This is my JSP page: <%@ taglib uri="/tags/struts-bean" prefix="bean" %> <%@ taglib uri="/tags/struts-html" prefix="html" %> <%@ taglib uri="/tags/struts-logic" prefix="logic" %> <html:html locale="true"> <head> <title>Blog</title> <html:base/> </head> <body bgcolor="white"> <h1>Blog</h1> <jsp:useBean id="blog" scope="request" class="com.vortex.blog.BlogBean"/> <logic:iterate name="blog" property="blogItem" id="blogItem"> <bean:write name="blogItem" property="title" filter="true"/> </logic:iterate> </body> </html:html> This is the error message: HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: Exception thrown by getter for property blogItem of bean blog org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageCont extImpl.java:846) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContex tImpl.java:779) org.apache.jsp.pages.Blog_jsp._jspService(Blog_jsp.java:153) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.ja va:325) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFi lter.java:362) org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.jav a:1063) org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProc essor.java:263) org.apache.struts.action.RequestProcessor.internalModuleRelativeForward( RequestProcessor.java:1001) org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForw ard(TilesRequestProcessor.java:345) org.apache.struts.action.RequestProcessor.processForward(RequestProcesso r.java:560) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java: 209) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:689) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFi lter.java:362) root cause javax.servlet.jsp.JspException: Exception thrown by getter for property blogItem of bean blog org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:968) org.apache.struts.taglib.logic.IterateTag.doStartTag(IterateTag.java:232 ) org.apache.jsp.pages.Blog_jsp._jspService(Blog_jsp.java:108) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.ja va:325) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFi lter.java:362) org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.jav a:1063) org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProc essor.java:263) org.apache.struts.action.RequestProcessor.internalModuleRelativeForward( RequestProcessor.java:1001) org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForw ard(TilesRequestProcessor.java:345) org.apache.struts.action.RequestProcessor.processForward(RequestProcesso r.java:560) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java: 209) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:689) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFi lter.java:362) note The full stack trace of the root cause is available in the Apache Tomcat/5.5.7 logs. Apache Tomcat/5.5.7 This is my javabean BlogBean.java: /* * BlogAction.java * * Created on 23 juni 2005, 20:05 * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package com.vortex.blog; import org.apache.struts.action.Action; import java.util.Iterator; import org.hibernate.*; import org.hibernate.cfg.*; /** * * @author Paternotte */ public class BlogBean implements java.io.Serializable { private Iterator blogItem; /** Creates a new instance of BlogAction */ public BlogBean() { } public Iterator getBlogItem() { Session session = HibernateUtil.currentSession(); Transaction tx = session.beginTransaction(); Query query = session.createQuery("select b from BlogItem as b"); blogItem = query.iterate(); tx.commit(); HibernateUtil.closeSession(); return blogItem; } } HibernateUtil.java copied straight from the Hibernate documentation. Thanks in advance, Jeroen ____________________________________________________ Yahoo! Sports Rekindle the Rivalries. Sign up for Fantasy Football http://football.fantasysports.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ----------------------------------------------------------------- ATTENTION: The information in this electronic mail message is private and confidential, and only intended for the addressee. Should you receive this message by mistake, you are hereby notified that any disclosure, reproduction, distribution or use of this message is strictly prohibited. Please inform the sender by reply transmission and delete the message without copying or opening it. Messages and attachments are scanned for all viruses known. If this message contains password-protected attachments, the files have NOT been scanned for viruses by the ING mail domain. Always scan attachments before opening them. ----------------------------------------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]