• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Building Session Factory - Null pointer Exception

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Paper beats rock. Scissors beats tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic