-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 posts ] 
Author Message
 Post subject: Hibernate Configuration Problem
PostPosted: Tue Aug 22, 2006 10:35 am 
Newbie

Joined: Thu Aug 17, 2006 8:02 am
Posts: 9
Hi,

I am using the Hibernate Configuration and whenever I create an object of the configuration in my Java code i get the following error:

%%%% Error Creating HibernateSessionFactory %%%%

java.lang.NullPointerException

at de.laliluna.example2.InitSessionFactory.initSessionFactory(InitSessio

nFactory.java:51)

at de.laliluna.example2.InitSessionFactory.getInstance(InitSessionFactor

y.java:33)

at de.laliluna.example.TestClient.main(TestClient.java:45)

Could not initialize the Hibernate configuration

Exception in thread "main" java.lang.NullPointerException

at de.laliluna.example.TestClient.main(TestClient.java:67)

Please guide where I am wrong


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 22, 2006 11:05 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
well, it appears you have an exception in the TestClient class on line 67. Thats about all I can tell you from what you've provided.

Perhaps the source code, the config.xml file, maybe more of the log files would help.

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 22, 2006 11:32 pm 
Newbie

Joined: Thu Aug 17, 2006 8:02 am
Posts: 9
Line 67 is
org.hibernate.cfg.Configuration cfg = new org.hibernate.cfg.Configuration();


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 1:43 am 
Regular
Regular

Joined: Fri Aug 18, 2006 2:40 pm
Posts: 51
Location: Metz, France
post your config.xml

_________________
Denis
Don't forget to rate ... thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 1:49 am 
Newbie

Joined: Thu Aug 17, 2006 8:02 am
Posts: 9
<?xml version='1.0' encoding='utf-8'?>

<!DOCTYPE hibernate-configuration SYSTEM "hibernate-configuration-3.0.dtd">


<hibernate-configuration>

<session-factory>

<property name="connection.url">jdbc:db2://au200ewp0549:50000/WESTPAC3</property>
<!-- <property name="connection.datasource">java:/comp/env/jdbc/testhibernate</property> -->
<property name="connection.username">db2admin</property>
<property name="connection.password">db2@westpac</property>
<property name="connection.driver_class">com.ibm.db2.jcc.DB2Driver</property>
<property name="dialect">org.hibernate.dialect.DB2Dialect</property>

<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>

<!-- thread is the short name for
org.hibernate.context.ThreadLocalSessionContext
and let Hibernate bind the session automatically to the thread -->
<property name="current_session_context_class">thread</property>
<!-- this will show us all sql statements -->
<property name="hibernate.show_sql">true</property>

<!-- mapping files -->
<mapping resource="de/laliluna/example/Appstatus.hbm.xml" />
</session-factory>

</hibernate-configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 1:58 am 
Regular
Regular

Joined: Fri Aug 18, 2006 2:40 pm
Posts: 51
Location: Metz, France
anjalisharma wrote:
<property name="current_session_context_class">thread</property>


property name is
hibernate.current_session_context_class

_________________
Denis
Don't forget to rate ... thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 2:09 am 
Newbie

Joined: Thu Aug 17, 2006 8:02 am
Posts: 9
But problem is not with the xml file.
problem is before calling the configure method, when we create the Configuration object.
Configuration cfg = new Configuration();

this line returns NullPointerException


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 3:35 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
Which jars do you have in your classpath/lib?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 4:46 am 
Regular
Regular

Joined: Fri Aug 18, 2006 2:40 pm
Posts: 51
Location: Metz, France
oops . forget it then.

_________________
Denis
Don't forget to rate ... thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 5:17 am 
Newbie

Joined: Thu Aug 17, 2006 8:02 am
Posts: 9
All the jars of hibernate package from hibernate.org


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 8:08 am 
Regular
Regular

Joined: Fri Aug 18, 2006 2:40 pm
Posts: 51
Location: Metz, France
Code:
java.lang.NullPointerException
at de.laliluna.example2.InitSessionFactory.initSessionFactory(InitSessio
nFactory.java:51)


the method that caused the null pointer is the first show in the stack trace
then you have to post your
InitSessionFactory.java

but line 51 is the most interresting

_________________
Denis
Don't forget to rate ... thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 28, 2006 7:44 am 
Newbie

Joined: Thu Aug 17, 2006 8:02 am
Posts: 9
Hibernate problem
While executing the simple hibernate example

Error in the line

session.beginTransaction();

Error is "cannot open connection"

Please suggest to solve the problem.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 30, 2006 2:18 am 
Newbie

Joined: Thu Aug 17, 2006 8:02 am
Posts: 9
Problem at line
Transaction tx = session.beginTransaction();

Cannot open connection
org.hibernate.exception.JDBCConnectionException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.j
ava:74)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelp
er.java:43)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelp
er.java:29)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager
.java:420)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.
java:144)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:129)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:
57)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1290
)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtection
Wrapper.invoke(ThreadLocalSessionContext.java:301)
at $Proxy0.beginTransaction(Unknown Source)
at de.laliluna.example.TestClient.main(TestClient.java:59)
Caused by: java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:532)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnectio
n(DriverManagerConnectionProvider.java:110)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager
.java:417)
... 11 more


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.