-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4275209
By: ananban
This is my zul script
<zscript>
import org.hibernate.*;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import cfo.persistence.HibernateUtil;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
void selectProjects() {
Session session
= HibernateUtil.getSessionFactory().getCurrentSession();
}
</zscript>
And this is HibernateUtil class
package cfo.persistence;
import org.hibernate.*;
import org.hibernate.cfg.*;
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
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 SessionFactory getSessionFactory() {
return sessionFactory;
}
}
Everything is good when i test in Eclipse but when i export it as jar and use it in zk (i also import all the needed lib ,zklib hibernatelib mylib,in my web project )i found that this line always got error in my zul script
void selectProjects() {
Session session
= HibernateUtil.getSessionFactory().getCurrentSession();
}
the error window said that : Unknow exception:java.lang.noclassdeffounderror
i may config something wrong or i may misunderstand something. How can i solve this Error or catch more exception?
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4275263
By: ananban
Which path must i put the "hibernate.cgf.xml" on in my netbean web project.
(by default of bibernate)?
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4279474
By: robbiecheng
This file should be put under the classpath of your project.
/Robbie
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4280856
By: magic003
I think that's not the problem of your hibernate.cfg.xml file. Copy asm.jar from the hibernate dist and replace the current one. And remember to use the the asm.jar from hibernate dist instead of that from ZK dist when you integrate ZK with Hibernate.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4281181
By: ananban
I thought that replace the ZK 's asm.jar with Hibernate 's asm.jar is already make my work go one more step further,but i still got the same error window :" Unknow exception:java.lang.noclassdeffounderror "
Are there anything else i must try? anyway thanks for your help.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4281248
By: ananban
Everything is fine now. I just clean all my project and rebuild it then it work now.
By the way , I really want to know about hibernate config file default path more deeply. Plz show me the example of some Project tree. Should it be look like this?
WEB-INF/lib
+-*myhibernate.jar
+-*package
| +-*Person.class
| +-*Person.hbm.xml
*hibernate.cfg.xml
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4283103
By: robbiecheng
Yes, hibernate.cfg.xml should be put in the root of classpath.
/Robbie
Asked: 2007-04-23 06:41:07 +0800
Seen: 194 times
Last updated: Apr 27 '07