aspose file tools*
The moose likes Object Relational Mapping and the fly likes java.lang.NullPointerException 	at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "java.lang.NullPointerException 	at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper." Watch "java.lang.NullPointerException 	at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper." New topic
Author

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

Jeetu Das
Greenhorn

Joined: May 12, 2012
Posts: 12
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
Hemant Thard
Ranch Hand

Joined: Dec 23, 2008
Posts: 122
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

Joined: May 12, 2012
Posts: 12
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

Joined: May 12, 2012
Posts: 12
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)
Manuel Petermann
Ranch Hand

Joined: Jul 19, 2011
Posts: 175

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.


Please correct my English.
Jeetu Das
Greenhorn

Joined: May 12, 2012
Posts: 12
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 .
 
Consider Paul's rocket mass heater.
 
subject: java.lang.NullPointerException at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.
 
Similar Threads
developing spell checker?
how to make a method in database access class for login
Unable to compile class for JSP
java.lang.NoClassDefFoundError
I got http-500 error in servlet and jsp.how to find error?