Trying to get hibernate working w/ struts. Followed the instructions here for the plugin:
http://www.hibernate.org/105.html
hibernate.cfg.xml :
Code:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="java:/hibernate/SessionFactory">
<property name="connection.datasource">java:/CummingsDB</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hbm2ddl.auto">update</property>
<mapping resource="Trailers.hbm.xml"/>
<mapping resource="TrailerSales.hbm.xml"/>
<mapping resource="Customers.hbm.xml"/>
<mapping resource="Makes.hbm.xml"/>
<mapping resource="Provinces.hbm.xml"/>
<mapping resource="Countries.hbm.xml"/>
</session-factory>
</hibernate-configuration>
I'm trying to instantiate like this :
Code:
SessionFactory sf = null;
Session session = null;
Context ctx;
try {
ctx = new InitialContext();
sf = (SessionFactory) ctx.lookup("java:/hibernate/SessionFactory");
session = sf.openSession();
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
I just get null pointer exception:
java.lang.NullPointerException
org.apache.jsp.inventoryForm_jsp._jspService(org.apache.jsp.inventoryForm_jsp:122)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1054)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:386)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1192)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:412)
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)