aspose file tools*
The moose likes Object Relational Mapping and the fly likes NullPointerException in hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "NullPointerException in hibernate" Watch "NullPointerException in hibernate" New topic
Author

NullPointerException in hibernate

sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1131
i am new to hibernate.so i am doing tutorials

this is my config.xml file



this is my mapping xml file
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">

com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">

jdbc:mysql://localhost/hibernatetutorial</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- Mapping files -->
<mapping resource="contact.hbm.xml"/>
</session-factory>
</hibernate-configuration>


this is my drriver class


but i am use debuging mode.then i found that this line gives in the driver class gives class not found exception.
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3102
    
  40

aruna sameera wrote: i found that this line gives in the driver class gives class not found exception.
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();


Aruna, I'm not highly sure, but it seems that some required library JAR files are NOT included in your application classpath appropriately.

Devaka.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3832

Why these mapping xml and config.xml files? Both are same? It should be hibernate.cfg.xml (default). And do you have the proper contact.hbm.xml?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Also a word of advice: the roseindia tutorials are full of bugs. I'm not sure I would try to use them to learn Hibernate.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Lalit Bhatt
Ranch Hand

Joined: Dec 27, 2007
Posts: 69

If you can tell which class is not found it will be easier.

If it is driver class which I am guessing from your mail than make sure you have mysql driver class in your path.


Java-JavaEE Hibernate Spring Software Development Business Process Analysis
Shashank Rudra
Ranch Hand

Joined: Mar 26, 2009
Posts: 131
Apart from what Paul have suggested - this happens when there is a mismatch in various(incompatible versions of) jar files. The same was in my case. I used different set of jars and it led me through.


Programmer Analyst || J2EE web development/design
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: NullPointerException in hibernate