wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Building Session Factory - Null pointer Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Building Session Factory - Null pointer Exception" Watch "Building Session Factory - Null pointer Exception" New topic
Author

Building Session Factory - Null pointer Exception

Dinakar Manchi
Greenhorn

Joined: Oct 09, 2008
Posts: 2
Hi all... here is my code.

Car.java
---------

========================================================

Driver.java
-----------

===================================================================

Person.java
-----------

===============================================================
HibernatePersonCarExample.java (Action Servlet)
----------------------------------------------

=======================================================

=================================================================
person.hbm.xml
--------------

====================================================
Car.hbm.xml
------------

================================================================

I GET THE FOLLOWING ERROR WHEN HITTING THE ACTION SERVLET:


01:06:21,640 INFO [SettingsFactory] Query language substitutions: {}
01:06:21,640 INFO [TransactionFactoryFactory] Transaction strategy: org.hiberna
te.transaction.JDBCTransactionFactory
01:06:21,640 INFO [TransactionManagerLookupFactory] No TransactionManagerLookup
configured (in JTA environment, use of read-write or transactional second-level
cache is not recommended)
01:06:21,640 INFO [SettingsFactory] Automatic flush during beforeCompletion():
disabled
01:06:21,640 INFO [SettingsFactory] Automatic session close at end of transacti
on: disabled
01:06:21,640 INFO [SettingsFactory] Second-level cache: enabled
01:06:21,640 INFO [SettingsFactory] Query cache: disabled
01:06:21,640 INFO [SettingsFactory] Cache provider: org.hibernate.cache.EhCache
Provider
01:06:21,640 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
01:06:21,640 INFO [SettingsFactory] Structured second-level cache entries: enab
led
01:06:21,640 INFO [SettingsFactory] Echoing all SQL to stdout
01:06:21,640 INFO [SettingsFactory] Statistics: disabled
01:06:21,640 INFO [SettingsFactory] Deleted entity synthetic identifier rollbac
k: disabled
01:06:21,640 INFO [SettingsFactory] Default entity-mode: pojo
01:06:21,656 INFO [SessionFactoryImpl] building session factory
01:06:21,703 WARN [RequestProcessor] Unhandled Exception thrown: class java.lan
g.NullPointerException
01:06:21,703 ERROR [[action]] Servlet.service() for servlet action threw excepti
on
java.lang.NullPointerException
at hibernate.example.Driver.setupSession(Driver.java:49)
at hibernate.example.HibernatePersonCarExample.execute(HibernatePersonCa
rExample.java:61)
at org.apache.struts.action.RequestProcessor.processActionPerform(Reques
tProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:119
6)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
lter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrinc
ipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
yAssociationValve.java:153)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
e.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor
kerThread.java:112)

---------------------------------------------------------------------------

Any help is greatly appreciated.

Thanks
Dinakar.

[ Edited to use code tags - Paul Sturrock ]
[ October 10, 2008: Message edited by: Paul Sturrock ]
John Catron
Greenhorn

Joined: Oct 17, 2008
Posts: 3
One thing to always check for is that if what you are trying to .close() is not already null.

i.e.



HTH
John Catron
Greenhorn

Joined: Oct 17, 2008
Posts: 3
Also, you are checking to see if the session is null, but then you are using the session. it should be more like :


[ October 20, 2008: Message edited by: J, Catron ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Building Session Factory - Null pointer Exception