-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problems with Hibernnate and Tomcat
PostPosted: Fri May 27, 2011 8:21 am 
Newbie

Joined: Fri May 27, 2011 8:00 am
Posts: 2
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.WebApplicationImpl 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>(HibernateUtil.java:16)
at app.server.user.AndroidUserManager.getUser(AndroidUserManager.java:24)
at app.server.user.AndroidUserManager.getUser(AndroidUserManager.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.MySQLDialect</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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.