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: Problem Involving Web Apps
PostPosted: Mon Jan 15, 2007 11:54 pm 
Newbie

Joined: Mon Jan 15, 2007 11:03 pm
Posts: 2
I have lately been trying to use Hibernate to develop a web application for Tomcat, which I have successfully written and tested using Eclipse's web tools. When I publish the web application with Eclipse, it works fine. But when I put the .war file in Tomcat's web-apps directory and start it normally, it gives me the following error:

INFO: Deploying web application archive webappname.war
Starting the Hibernate listener
Initial SessionFactory creation failed.
java.lang.NoClassDefFoundError: net.sf.cglib.core.DebuggingClassWriter$1
java.lang.NoClassDefFoundError: net.sf.cglib.core.DebuggingClassWriter$1
at java.lang.Class.initializeClass(libgcj.so.7rh)
at net.sf.cglib.core.DebuggingClassWriter.toByteArray(DebuggingClassWriter.java:73)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:26)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
at java.lang.Class.initializeClass(libgcj.so.7rh)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:107)
at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:135)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:269)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:425)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1291)
at mypackage.HibernateUtil.<clinit>(HibernateUtil.java:17)
at java.lang.Class.initializeClass(libgcj.so.7rh)
at mypackage.HibernateListener.contextInitialized(HibernateListener.java:19)

The stack trace is quite long, but unfortunately there is no pertinent error information after that.

The problem seems to be that the Hibernate listener, which runs when the web application is instantiated and is intended to create a SessionFactory for Hibernate, fails. The code for getting the SessionFactory is from HibernateUtil, from http://www.hibernate.org/42.html#A11 and the configuration file is based on the one found in http://www.hibernate.org/114.html.

At first glance, I thought this problem was merely that one of Hibernate's third-party jars was missing from WEB-INF/lib, but I checked, and hibernate3.jar, the JDBC driver, and all the third-party JARs were in the directory, including cglib.

Is there any kind of security feature on Tomcat that makes this not work? What is so strange to me is that when I published it using Eclipse's web tools, it worked fine. Only when I tried using a WAR did this become a problem.

Any help would be very much appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 16, 2007 4:10 am 
Newbie

Joined: Mon Jan 15, 2007 3:22 pm
Posts: 6
Not being familiar with Eclipse web publishing or cglib, I doubt I can be much help, but I do know Tomcat:

Putting a JAR in the WEB-INF/lib directory of your WAR is enough for the classes to be made available on the classpath for your web application. You might want to experiment with placing the lib JARs in shared/lib to see if that makes any difference (this is where libraries that are to be shared between apps reside). However, the Tomcat auto-deploy feature can be less than reliable. Go and look in the webapps directory of your Tomcat install and make sure that the WAR has expanded correctly. I have often seen Tomcat partially expand a deployed web application (especially on Windows).

Looking at the stack trace, the NoClassDefFound error is being thrown for what looks like an anonymous subclass of DebuggingClassWriter. Further up the stack trace, however, you can see that the exception is thrown from within DebuggingClassWriter.toByteArray i.e. the main class has loaded OK, suggesting that the JAR is present. In my experience, the other big cause of NoClassDefFoundErrors is if an exception is thrown in a static initialiser - Java marks the class as not found in such cases.

Matt


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.