Hi All,
I' m trying to run first example from "Hibernate Made Easy" and getting this error.
Quote:
50 [main] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.2.0.Final
60 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.6.0.Final
Exception in thread "main" java.lang.ExceptionInInitializerError
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.examscam.model.User.main(User.java:42)
Caused by: java.lang.NullPointerException
at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:167)
at org.hibernate.cfg.Environment.<clinit>(Environment.java:608)
... 4 more
User.java class code is as follow:
Code:
package com.examscam.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
@Entity
public class User {
@Id
@GeneratedValue
private Long id;
private String password;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@SuppressWarnings("deprecation")
public static void main(String[] args) {
// TODO Auto-generated method stub
AnnotationConfiguration config = new AnnotationConfiguration();
config.addAnnotatedClass(User.class);
new SchemaExport(config).create(true, true);
}
}
and hibernate.cf.xml code is as follow:
Code:
<?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">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/examscam</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">123</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="current_session_context_class">thread</property>
<property name="hibernate.show_sql">true</property>
</session-factory>
</hibernate-configuration>
jar files included are as follow
http://www.flickr.com/photos/31053338@N03/5371762878/My Environment is as follow:
Working Environment:
MySQL 5.5.8
jdk1.6.0_23
Eclipse 3.6 Helios
Hibernate 3.6.0
I tried myself to correct first by searching forum and internet before writing this post but failed so please help me in this regard. Thanks