-->
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.  [ 2 posts ] 
Author Message
 Post subject: jsp project with hibernate (create sesion problem)
PostPosted: Tue Nov 11, 2008 9:58 am 
Newbie

Joined: Tue Nov 11, 2008 9:42 am
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
hibernate3.jar
Mapping documents:
dynamic web project
Code between sessionFactory.openSession() and session.close():
protected void doPost(HttpServletRequest request, HttpServletResponse response)
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;



public class HibernateUtil implements java.io.Serializable {

public static final SessionFactory sessionFactory;

static {
try {

// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new Configuration().configure().buildSessionFactory();

} 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);
}

}


public static final ThreadLocal session = new ThreadLocal();

public static Session currentSession() throws HibernateException {
Session s = (Session) session.get();
// Open a new Session, if this thread has none yet
if (s == null) {
s = sessionFactory.openSession();
// Store it in the ThreadLocal variable
session.set(s);

}
return s;
}

public static void closeSession() throws HibernateException {
Session s = (Session) session.get();
if (s != null)
s.close();
session.set(null);

}
Full stack trace of any exception that occurs:
11.11.2008 14:53:59 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The Apache Portable Runtime which allows optimal performance in production environments was not found on the java.library.path: D:\Program Files\Java\jdk1.6.0_10\bin;.;D:\WINDOWS\Sun\Java\bin;D:\WINDOWS\system32;D:\WINDOWS;D:/Program Files/Java/jre6/bin/client;D:/Program Files/Java/jre6/bin;D:\WINDOWS\system32;D:\WINDOWS;D:\WINDOWS\System32\Wbem;D:\Program Files\Java\jre1.6.0_07;D:\Program Files\Java\jdk1.6.0_10;C:\AppServ\Apache2.2\bin;C:\AppServ\php5;C:\AppServ\MySQL\bin;D:\Program Files\Java\jdk1.6.0_10\bin;D:\Program Files\Java\jdk1.6.0_10\jre\bin
11.11.2008 14:53:59 org.apache.coyote.http11.Http11BaseProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-80
11.11.2008 14:53:59 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 625 ms
11.11.2008 14:53:59 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
11.11.2008 14:53:59 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.12
11.11.2008 14:53:59 org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/dom4j/DocumentException
11.11.2008 14:54:00 org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet Init as unavailable
11.11.2008 14:54:00 org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /Portability_web threw load() exception
java.lang.ExceptionInInitializerError
at util.HibernateUtil.<clinit>(HibernateUtil.java:29)
at servlet.Init.<init>(Init.java:43)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1048)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:925)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3880)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4141)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:680)
at org.apache.catalina.startup.Catalina.start(Catalina.java:536)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Caused by: java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at util.HibernateUtil.<clinit>(HibernateUtil.java:24)
... 24 more
Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 25 more
11.11.2008 14:54:00 org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-80
11.11.2008 14:54:00 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
11.11.2008 14:54:00 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/32 config=null
11.11.2008 14:54:00 org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
11.11.2008 14:54:00 org.apache.catalina.startup.Catalina start
INFO: Server startup in 844 ms
Name and version of the database you are using:
mysql 5.0
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


i' m read all google stuff about my problem, but i dons't resolved my problem yet.
Please help.

have a nice day.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 12, 2008 7:57 am 
Newbie

Joined: Fri Sep 26, 2008 4:01 am
Posts: 10
Quote:
Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException


I guess U r missing a library in the deployed package.
If using eclipse set it as JEE dependency

JAVA BUILD PATH ->JEE dependency.

Verify that the dom4j lib is in the WEB-INF\lib\
I hope this helps.... if so just dont forget to rate :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.