-->
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.  [ 6 posts ] 
Author Message
 Post subject: Problem Hibernate 3.2.0 tutorial on tomcat-5.5.17
PostPosted: Wed Apr 18, 2007 9:53 am 
Newbie

Joined: Wed Apr 18, 2007 8:39 am
Posts: 4
Hi, I'm a newbie on Hibernate and got to the end of the tutorial when I had to deploy the resulting war file on Tomcat and trouble began (Tc does work with other apps). Whatever I try I see one of these two exceptions

javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.ExceptionInInitializerError
util.HibernateUtil.<clinit>(Unknown Source)
events.EventManagerServlet.doGet(Unknown Source)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

or

javax.servlet.ServletException: Servlet execution threw an exception
java.lang.NoClassDefFoundError
events.EventManagerServlet.doGet(Unknown Source)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

Now the directory structure of my project is:

C:\HibernateTutorial>
│ build.xml
│ log4j.properties
│ web.xml
├───data
├───lib
│ antlr-2.7.6.jar
│ asm-attrs.jar
│ asm.jar
│ cglib-2.1.3.jar
│ commons-collections-2.1.1.jar
│ commons-logging-1.0.4.jar
│ dom4j-1.6.1.jar
│ hibernate3.jar
│ hsqldb.jar
│ jboss-cache.jar
│ jsp-api.jar
│ jsse.jar
│ jta.jar
│ log4j-1.2.11.jar
│ mysql-connector-java-3.0.17-ga-bin.jar
│ readme.txt
└───src
│ hibernate.cfg.xml
├───events
│ Event.hbm.xml
│ Event.java
│ EventManager.java
│ EventManagerServlet.java
│ Person.hbm.xml
│ Person.java
└───util
HibernateUtil.java

Changes I made while testing: I changed <hibernate-mapping> in hbm.xml files into <hibernate-mapping package="events">, I added jboss-cache.jar to lib, changed log4j.properties into version with log4j.rootLogger=debug, stdout, and after deploying war file on Tomcat added copy of log4j.properties to C:\tc5\webapps\hibernate-tutorial\WEB-INF\classes.

CLASSPATH = .;C:\tc5\common\lib\servlet-api.jar;C:\tc5\common\lib\jsp-api.jar;C:\Servlets+JSP;C:\mysqcon\mysql-connector-java-3.0.17-ga-bin.jar;

ANT_HOME = C:\apache-ant-1.6.5

CATALINA_HOME = C:\tc5

JAVA_HOME = C:\Program Files\Java\jdk1.5.0_11

Path = %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\MySQL\MySQL Server 4.1\bin;C:\apache-ant-1.6.5\bin;C:\Program Files\Java\jdk1.5.0_11\bin";%PATH%

I'm slightly going nuts here.
Can somebody PLEASE help me out?
Cheers
Kees


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 18, 2007 11:36 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Why don't you use the WORKING source that comes with the tutorial and compare it to yours?

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 18, 2007 7:11 pm 
Newbie

Joined: Wed Apr 18, 2007 8:39 am
Posts: 4
christian wrote:
Why don't you use the WORKING source that comes with the tutorial and compare it to yours?

I'll do that, thanks. After a day of trial and error you can miss the obvious ;)
I'll post the results here.
Cheers,
Kees


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 19, 2007 4:53 am 
Newbie

Joined: Wed Apr 18, 2007 8:39 am
Posts: 4
Well that wasn't very helpful unfortunately: the lib directory totally empty, web.xml lacking, and no further hints on configuration issues. After all not so obvious as one might think.
Anyone who succesfully deployed war file and run hibernate-tutorial demo-application from hibernate-3.2.0?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 19, 2007 5:07 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
There was a mistake in the Hibernate build, the web.xml was not included. It's in SVN and very very trivial:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
    xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <servlet>
        <servlet-name>Event Manager</servlet-name>
        <servlet-class>events.EventManagerServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>Event Manager</servlet-name>
        <url-pattern>/eventmanager</url-pattern>
    </servlet-mapping>
</web-app>


There is nothing else to configure. Of course the lib directory is empty, because we don't package the same libraries twice. Read the readme.txt in that directory.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 19, 2007 6:49 am 
Newbie

Joined: Wed Apr 18, 2007 8:39 am
Posts: 4
Hi Christian,
That web.xml was identical to the one I got from the tutorial.html.
After that I decided to compare code in source files and discovered some differences

1. in Event.hbm.xml: I had the
<set name="participants" table="PERSON_EVENT" inverse="true">
outside the <class name="events.Event" table="EVENTS"> declaration

2. Event.java: I had setParticipants(Set participants) as protected method i.o. public (while tutorial.html declares it as private...)

3. EventManager.java: I didn't have org.hibernate.criterion.Expression imported and the tutorial.html didn't mention adding a main attribute "addemailtoperson" so I erroniously concluded it was meant for Person.java

After compiling the revised version into war file and deploying it I first got a TransactionException which was caused by not having started HSQLDB.

Finally got it working.
The tutorial.html is really great (looks like it got copied partly into the book Java Persistance with Hibernate) but description is not 100% exact so it takes some trial and error and support to get it running.
Thanks for your time!
Kees


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

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.