Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hi,
I am developing a simple Hibernate code to run on a websphere portal server 5.1.0.1. I took the sample from Hibernate tutorial and when ran as a java program it works fine. But running on the server it is giving a class not found and give me an exception:
Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org.hibernate.cfg.Configuration
In my config file I tried running using either the JDBC url or using datasource. But none of them works. The code goes to the catch block when it comes to SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Hibernate version: 3.2
Mapping documents:
<session-factory>
<!-- Database connection settings -->
<!-- <property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.driver_class">com.ibm.db2.jcc.DB2Driver</property> -->
<!-- <property name="connection.url">jdbc:hsqldb:hsql://localhost</property>
<property name="connection.url">jdbc:db2://localhost:50000/SAMPLE</property> -->
<property name="hibernate.connection.datasource">java:/comp/env/jdbc/test</property>
<property name="connection.username">db2admin</property>
<property name="connection.password">db2admin</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">10</property>
<!-- SQL dialect -->
<!-- <property name="dialect">org.hibernate.dialect.HSQLDialect</property> -->
<property name="hibernate.dialect">org.hibernate.dialect.DB2Dialect</property>
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
<mapping resource="events/Event.hbm.xml"/>
</session-factory>
Code between sessionFactory.openSession() and session.close():
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
Event theEvent = new Event();
theEvent.setTitle(title);
theEvent.setDate(theDate);
session.save(theEvent);
session.getTransaction().commit();
session.close();
Full stack trace of any exception that occurs:
R Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org.hibernate.cfg.Configuration
[11/14/06 15:11:28:649 EST] 11df11df SystemErr R java.lang.NoClassDefFoundError: org.hibernate.cfg.Configuration
[11/14/06 15:11:28:978 EST] 11df11df SystemErr R at java.lang.Throwable.<init>(Throwable.java:59)
[11/14/06 15:11:28:978 EST] 11df11df SystemErr R at java.lang.Throwable.<init>(Throwable.java:73)
[11/14/06 15:11:28:978 EST] 11df11df SystemErr R at java.lang.Class.initialize(Class.java:318)
[11/14/06 15:11:28:978 EST] 11df11df SystemErr R at testhibernate.TestHibernatePortlet.doView(TestHibernatePortlet.java)
Name and version of the database you are using: DB2 Express C
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html