This week's giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of liveProject: Build an ML Recommender System and have Kim Falk on-line!
See this thread for details.
Win a copy of liveProject: Build an ML Recommender System this week in the Artificial Intelligence and Machine Learning forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

java.lang.NullPointerException at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I am getting the following error , while reading the hibernate.config.xml file .
Please help .


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: Servlet execution threw an exception


root cause

java.lang.ExceptionInInitializerError
org.hibernate.cfg.Configuration.reset(Configuration.java:330)
org.hibernate.cfg.Configuration.<init>(Configuration.java:296)
org.hibernate.cfg.Configuration.<init>(Configuration.java:300)
com.jitu.core.HibernateUtil.sessionFactory(HibernateUtil.java:11)
com.jitu.http.server.CreateUserServlet.doPost(CreateUserServlet.java:41)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause

java.lang.NullPointerException
org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:167)
org.hibernate.cfg.Environment.<clinit>(Environment.java:608)
org.hibernate.cfg.Configuration.reset(Configuration.java:330)
org.hibernate.cfg.Configuration.<init>(Configuration.java:296)
org.hibernate.cfg.Configuration.<init>(Configuration.java:300)
com.jitu.core.HibernateUtil.sessionFactory(HibernateUtil.java:11)
com.jitu.http.server.CreateUserServlet.doPost(CreateUserServlet.java:41)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.35 logs.


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

Apache Tomcat/6.0.35
 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Please post your cfg.xml file.

With this information, it will be difficult for us to predict what can be wrong in your code.

Regards,
Hemant
 
Jeetu Das
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI ..Thanks for the reply .

cfg.xml

<?xml version='1.0' encoding='utf-8'?>

<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd" >

<hibernate-configuration>

<session-factory>

<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>

<property name="hibernate.connection.url">jdbcracle:thin:@TRAINHR1011:1521:RETAILS</property>

<property name="hibernate.connection.username">fcr</property>

<property name="hibernate.connection.password">fcr</property>

<property name="hibernate.connection.pool_size">1</property>

<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>

<property name="show_sql">true</property>

<property name="hibernate.hbm2ddl.auto">update</property>

<!-- Mapping files -->



</session-factory>

</hibernate-configuration>



I have added some jars in the class path , now i am getting the following error :

java.lang.ExceptionInInitializerError
org.hibernate.cfg.Configuration.reset(Configuration.java:330)
org.hibernate.cfg.Configuration.<init>(Configuration.java:296)
org.hibernate.cfg.Configuration.<init>(Configuration.java:300)
com.jitu.core.HibernateUtil.sessionFactory(HibernateUtil.java:11)
com.jitu.http.server.CreateUserServlet.doPost(CreateUserServlet.java:41)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause

java.lang.NullPointerException
org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:167)
org.hibernate.cfg.Environment.<clinit>(Environment.java:608)
org.hibernate.cfg.Configuration.reset(Configuration.java:330)
org.hibernate.cfg.Configuration.<init>(Configuration.java:296)
org.hibernate.cfg.Configuration.<init>(Configuration.java:300)
com.jitu.core.HibernateUtil.sessionFactory(HibernateUtil.java:11)
com.jitu.http.server.CreateUserServlet.doPost(CreateUserServlet.java:41)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)




Please help me .
 
Jeetu Das
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May 24, 2012 6:14:33 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet CreateUserServlet threw exception
java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cfg.Environment
at org.hibernate.cfg.Configuration.reset(Configuration.java:330)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:296)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:300)
at com.jitu.core.HibernateUtil.sessionFactory(HibernateUtil.java:11)
at com.jitu.http.server.CreateUserServlet.doPost(CreateUserServlet.java:41)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
 
Ranch Hand
Posts: 177
Hibernate Python Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just posting stack traces isnt going to give us a clue what went wrong when you don't tell us what you did to get them... I assume you didnt add hibernate correctly to your classpath. But this is as good a guess as any.
 
Jeetu Das
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Sir,

I want to do a application which simply interact with DB and fetch the Data with a hibernate .

The settng i have done as follows :

Classpath : D:\oracle\product\10.2.0\client\jdbc\lib\classes12.jar;D:\oracle\product\10.2.0\client\jdbc\lib\ojdbc14.jar;D:\Software\ThirdPartyJard\ExternalJars\slf4j-api-1.6.1;D:\Software\ThirdPartyJard\ExternalJars\log4j.jar;D:\Software\ThirdPartyJard\ExternalJars\hibernate3.jar;


Includedthe following jars in bin and apache tomcat server .

1)slf4j-log4j12-1.6.1
2)slf4j-api-1.6.1
3)log4j
4)hibernate-jpa-2.0-api-1.0.0.Final
5)hibernate3

My Hibernate.cfg.xml file as below



My Hibernate Until Class :


I have put my cfg file inside my package .

If you need more information , please let me know .
 
Just let me do the talking. Ahem ... so ... you see ... we have this tiny ad...
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic