wood burning stoves 2.0*
The moose likes IDEs, Version Control and other tools and the fly likes potential eclipse problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "potential eclipse problem" Watch "potential eclipse problem" New topic
Author

potential eclipse problem

Michael Sampson
Ranch Hand

Joined: Sep 24, 2008
Posts: 30
I'm skipping some history on this which may not matter any way.... I am trying to launch a web app that uses spring.

The first error I am getting:

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile
at org.hibernate.ejb.packaging.AbstractJarVisitor.checkAnnotationMatching(AbstractJarVisitor.java:236)
at org.hibernate.ejb.packaging.AbstractJarVisitor.executeJavaElementFilter(AbstractJarVisitor.java:202)
at org.hibernate.ejb.packaging.AbstractJarVisitor.addElement(AbstractJarVisitor.java:163)
at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(ExplodedJarVisitor.java:101)
at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(ExplodedJarVisitor.java:109)
at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(ExplodedJarVisitor.java:109)
at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(ExplodedJarVisitor.java:109)
at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(ExplodedJarVisitor.java:109)
at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(ExplodedJarVisitor.java:109)
at org.hibernate.ejb.packaging.ExplodedJarVisitor.doProcessElements(ExplodedJarVisitor.java:67)
at org.hibernate.ejb.packaging.AbstractJarVisitor.getMatchingEntries(AbstractJarVisitor.java:139)
at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:287)
at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:614)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:360)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:131)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:224)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:291)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
... 30 more
Jul 7, 2009 8:35:24 AM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart

I see the big fat java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile but the stupifying thing to me is I have javassist-3.4.GA.jar in WEB-INF/lib. I thought this was may be a spring problem but I am thinking there is something goofy going on with the classpath set up with the eclipse ide I'm working in because javassist.bytecode.ClassFile is listed in the jar file in WEB-INF/lib so it seems like all the pieces are there. I may post this the spring forum as well.

Mike
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

I am confused at why instantiating an EntityManagerFactory would require byte code instrumentation with JavaAssist, but that doesn't really matter here.

I am also assuming that you are deploying on a Tomcat instance running in Eclipse. We are doing that here and we have the javaassist-3.7.GA.jar in our lib directory in our war and it seems to be working for us. We also have it in our Java Build Path - Libraries section in our project's properties. Check to see if you see it in your projects properties too, but I don't think that is it.


Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Michael Sampson
Ranch Hand

Joined: Sep 24, 2008
Posts: 30
Hi Mark,
thanks for the reply. Yes your assumption is correct in that I am trying to run tomcat web server from within eclipse. I checked properties for my project java build path-> libraries -> web app libraries and javaassist-3.7.GA.jar is present in WEBCONTECT/WEB-INF/lib folder. Your comment gave me an idea though, and that is to export to a war file and try to start in tomcat manually. I did that and I have bad version number errors. I am guessing that occurs due to a jre setting that is eclipse does not agree with what I use in tomcat. I can't tell if it is similar to underlying problem that causes the class not found exception. That original class not found error is tough to explain right now.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

This can be tricky. Spring/Tomcat needs an instrumented load-time weaver (I think that's the proper setup). As of Tomcat 6, that means a couple of things:

1. Altering Tomcat. Add the following to TOMCAT_HOME/lib:

spring-agent-2.5.4.jar
spring-tomcat-weaver-2.5.4.jar

You may have to dig through SpringSource to find them - they were camouflaged a bit when I got them.

2. Add the following to your Tomcat configuration in Eclipse / Help / Preferences / Tomcat / JVM Settings:

-javaagent:/home/timh/apache-tomcat-6.0.18/lib/spring-agent-2.5.4.jar

This is equivalent to putting the same statement in the TOMCAT_HOME/bin/setenv.sh file, but for the Eclipse embedded Tomcat.

3. Set up something like the following in the Spring configuration for your app:



The important part is the loadTimeWeaver.

This isn't exactly trivial, but once all the parts are in place, you can basically set it and forget it.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
Consider Paul's rocket mass heater.
 
subject: potential eclipse problem