0

Can't use hibernate and dont know whatto do

asked 2007-04-23 06:41:07 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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?

delete flag offensive retag edit

6 Replies

Sort by ยป oldest newest

answered 2007-04-23 07:35:11 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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)?

link publish delete flag offensive edit

answered 2007-04-25 10:20:34 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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

link publish delete flag offensive edit

answered 2007-04-26 02:46:48 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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.

link publish delete flag offensive edit

answered 2007-04-26 08:56:56 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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.

link publish delete flag offensive edit

answered 2007-04-26 09:35:34 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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


link publish delete flag offensive edit

answered 2007-04-27 00:38:22 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2007-04-23 06:41:07 +0800

Seen: 194 times

Last updated: Apr 27 '07

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More