File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NullPointerException in hibernate

 
sam liya
Ranch Hand
Posts: 1240
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 4116
195
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Vijitha Kumara
Bartender
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Lalit Bhatt
Ranch Hand
Posts: 69
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Shashank Rudra
Ranch Hand
Posts: 131
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic