0

zk3.6.3 and Hibernate 3.5.5 problem

asked 2010-09-06 01:22:25 +0800

amar4kintu gravatar image amar4kintu
30 2

Hello friends,

I am new to zkoss and trying to learn zkoss.

I have downloaded zk3.6.3 and hibernate 3.5.5. I have apache tomacat 6.0 server on widow 2003 Operating System.

I am trying famous pet store example with it.

I have following in my web.xml file

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" 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">
	<display-name>
	zk3</display-name>
	<listener>
		<description>
		Used to cleanup when a session is destroyed</description>
		<display-name>
		ZK Session cleaner</display-name>
		<listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
	</listener>
	<servlet>
		<description>
		The ZK loader for ZUML pages</description>
		<servlet-name>zkLoader</servlet-name>
		<servlet-class>
		org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class>
		<init-param>
			<param-name>update-uri</param-name>
			<param-value>/zkau</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet>
		<description>
		The asynchronous update engine for ZK</description>
		<servlet-name>auEngine</servlet-name>
		<servlet-class>
		org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>zkLoader</servlet-name>
		<url-pattern>*.zul</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>zkLoader</servlet-name>
		<url-pattern>*.zhtml</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>auEngine</servlet-name>
		<url-pattern>/zkau/*</url-pattern>
	</servlet-mapping>
	<welcome-file-list>
		<welcome-file>index.html</welcome-file>
		<welcome-file>index.htm</welcome-file>
		<welcome-file>index.jsp</welcome-file>
		<welcome-file>default.html</welcome-file>
		<welcome-file>default.htm</welcome-file>
		<welcome-file>default.jsp</welcome-file>
		<welcome-file>index.zul</welcome-file>
	</welcome-file-list>
	
	<resource-ref>
		<res-ref-name>jdbc/hsql</res-ref-name>
		<res-type>javax.sql.DataSource</res-type>
		<res-auth>Container</res-auth>
	</resource-ref>
    
</web-app>


Following is my zk.xml file

<?xml version="1.0" encoding="UTF-8"?>

<!--
	Created by ZK Studio
-->

<zk>
	<device-config>
		<device-type>ajax</device-type>
		<timeout-uri>/timeout.zul</timeout-uri><!-- An empty URL can cause the browser to reload the same URL -->
	</device-config>
	
	<!-- Configure the Hibernate SessionFactory Lifecycle.-->
	<listener>
		
		<description>Hibernate SessionFactory Lifecycle</description>
		
		<listener-class>
			org.zkoss.zkplus.hibernate.HibernateSessionFactoryListener
		</listener-class>
		
	</listener>
	<!-- Configure the Hibernate "Open Session In View" Session Lifecycle -->
	<listener>
		
		<description>Hibernate "Open Session In View" Session Lifecycle</description>
		
		<listener-class>
			org.zkoss.zkplus.hibernate.OpenSessionInViewListener
		</listener-class>
		
	</listener>
	
	<!-- Hibernate thread session context handler -->
	<listener>
		
		<description>Hibernate thread session context handler</description>
		
		<listener-class>
			org.zkoss.zkplus.hibernate.HibernateSessionContextListener
		</listener-class>
		
	</listener>
</zk>


I have included hibernate3.jar which contains class org.hibernate.cfg.AnnotationConfiguration

But for some reason when I execute my file it gives me following error..

java.lang.ExceptionInInitializerError
org.zkoss.zkplus.hibernate.HibernateUtil.initSessionFactory(HibernateUtil.java:125)
org.zkoss.zkplus.hibernate.HibernateUtil.initSessionFactory(HibernateUtil.java:108)
org.zkoss.zkplus.hibernate.HibernateUtil.getSessionFactory(HibernateUtil.java:68)
org.zkoss.zkplus.hibernate.HibernateUtil.currentSession(HibernateUtil.java:75)
org.zkoss.zkplus.hibernate.OpenSessionInViewListener.init(OpenSessionInViewListener.java:54)
org.zkoss.zk.ui.util.Configuration.invokeExecutionInits(Configuration.java:812)
org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:346)
org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:299)
org.zkoss.zk.ui.http.DHtmlLayoutServlet.process(DHtmlLayoutServlet.java:229)
org.zkoss.zk.ui.http.DHtmlLayoutServlet.doGet(DHtmlLayoutServlet.java:165)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cfg.AnnotationConfiguration
org.zkoss.zkplus.hibernate.HibernateUtil.java5Factory(HibernateUtil.java:135)
org.zkoss.zkplus.hibernate.HibernateUtil.initSessionFactory(HibernateUtil.java:117)
org.zkoss.zkplus.hibernate.HibernateUtil.initSessionFactory(HibernateUtil.java:108)
org.zkoss.zkplus.hibernate.HibernateUtil.getSessionFactory(HibernateUtil.java:68)
org.zkoss.zkplus.hibernate.HibernateUtil.currentSession(HibernateUtil.java:75)
org.zkoss.zkplus.hibernate.OpenSessionInViewListener.init(OpenSessionInViewListener.java:54)
org.zkoss.zk.ui.util.Configuration.invokeExecutionInits(Configuration.java:812)
org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:346)
org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:299)
org.zkoss.zk.ui.http.DHtmlLayoutServlet.process(DHtmlLayoutServlet.java:229)
org.zkoss.zk.ui.http.DHtmlLayoutServlet.doGet(DHtmlLayoutServlet.java:165)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


Can anyone tell me what the problem should be?

Thanks.

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2010-09-06 20:25:03 +0800

SimonPai gravatar image SimonPai
1696 1

amar4kintu,

NoClassDefFoundError usually means you are missing some jars.
If my memory serves me right, Hibernate 3 requires more than hibernate3.jar to work.
Here you can find a list of required jars.

Regards,
Simon

link publish delete flag offensive edit

answered 2010-09-07 01:26:25 +0800

amar4kintu gravatar image amar4kintu
30 2

Hello SimonPai,

Thanks for your reply..

Regarding hibernate3.jar.. I have taken all jar files in my project.. and also error says that..

java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cfg.AnnotationConfiguration

but in my Eclipse editor I can see class org.hibernate.cfg.AnnotationConfiguration..

But I am not getting why zk is not able to get it??

Thanks.

link publish delete flag offensive edit

answered 2010-09-07 01:45:12 +0800

SimonPai gravatar image SimonPai
1696 1

amar4kintu,

I think the class comes from hibernate-annotations.jar, and supposely if you have the jars available under WEB-INF/lib, your servlet can access it.

Regards,
Simon

link publish delete flag offensive edit

answered 2010-09-07 02:29:43 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

Only a hint: You became the same error if the libs are double in your folder

link publish delete flag offensive edit

answered 2010-09-07 06:50:13 +0800

amar4kintu gravatar image amar4kintu
30 2

Hello SimonPai and terrytornado,

Thanks for your time and support.

I downloaded latest petshop.war file from http://sourceforge.net/projects/zkforge/files/ and import it using eclipse and take all jar files in that to my project and it worked fine.

So might be the problem with incompatibility of libraries.

Thanks.

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: 2010-09-06 01:22:25 +0800

Seen: 577 times

Last updated: Sep 07 '10

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