DZone Forums
Go Back   DZone Forums > Community > Languages & Frameworks > Java
Reload this Page Problems with Hibernnate and Tomcat
Notices
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  (#1 (permalink)) Old
Member
 
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: May 2011
Default Problems with Hibernnate and Tomcat - 05-27-2011, 08:06 AM

Hi,
I must say first that I am new to Hibernate and the code on which I am working is not written by me.
I am trying to configure an application, the server component of whose uses Hibernate to communicate with the database.
I have changed the config files to suit the configurations in my machine.
When I do a maven clean install of the server project, the test cases get successfully executed and hibernate tests are thus executed which means my configurations are actually correct.
However, After deploying the application to Tomcat, when I make a request to the server which uses hibernate to get data from the database, it throws exception in the HibernateUtil file which has basically the code as this :

private static SessionFactory buildSessionFactory() {
try {
// Create the SessionFactory from hibernate.cfg.xml
return new Configuration().configure().buildSessionFactory(); //// This line throws the exception
}
catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}

The stack trace from my log file says :

2011-maj-27 13:26:42 com.sun.jersey.server.impl.application.WebApplicat ionImpl mapMappableContainerException
ALLVARLIG: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container
java.lang.ExceptionInInitializerError
at app.server.model.HibernateUtil.buildSessionFactory (HibernateUtil.java:26)
at app.server.model.HibernateUtil.<clinit>(HibernateU til.java:16)
at app.server.user.AndroidUserManager.getUser(Android UserManager.java:24)
at app.server.user.AndroidUserManager.getUser(Android UserManager.java:48)

I have the following dependency for hibernate in my pom.xml



<!-- Hibernate library dependecy start -->
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>

<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>

<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>

<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2</version>
</dependency>
<!-- Hibernate library dependecy end -->

My hibernate.cfg.xml is like :

<hibernate-configuration>
<session-factory>
<property name="hibernate.bytecode.use_reflection_optimizer" >false</property>
<property name="hibernate.connection.driver_class">com.mysql .jdbc.Driver</property>
<property name="hibernate.connection.password">mysql</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/appdb</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.MyS QLDialect</property>
<property name="show_sql">false</property>
<mapping resource="Application.hbm.xml"></mapping>
<mapping resource="Category.hbm.xml"></mapping>
<mapping resource="User.hbm.xml"></mapping>
<mapping resource="Permission.hbm.xml"></mapping>
.....................
</session-factory>
</hibernate-configuration>

I am not getting any idea what is going wrong here.
Is there any Tomcat specific settings required here.
Thanks for reading and any help will be highly appreciated.

Thanks and Regards,
Abhiroop
Reply With Quote
Reply

Tags
hibernate, java, tomcat

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tomcat Problem ewanshoo Eclipse 0 09-25-2009 05:15 AM
How to run Tomcat from Eclipse on OS X ... knarfsnrub Eclipse 0 09-05-2009 07:45 PM
how to use tomcat with eclipse junaidg Eclipse 2 01-25-2009 10:28 PM
JSPs and Tomcat 5.5 skitmax81 Java 0 08-22-2008 10:23 AM
How to run Jsp without tomcat plugin shintu Eclipse 4 05-28-2008 06:37 AM


Copyright 1997-2009, DZone, Inc.
vBulletin Skin developed by: vBStyles.com