File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "potential eclipse problem" Watch "potential eclipse problem" New topic

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 Method)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(
at org.springframework.web.context.ContextLoader.initWebApplicationContext(
at org.springframework.web.context.ContextLoaderListener.contextInitialized(
at org.apache.catalina.core.StandardContext.listenerStart(
at org.apache.catalina.core.StandardContext.start(
at org.apache.catalina.core.ContainerBase.start(
at org.apache.catalina.core.StandardHost.start(
at org.apache.catalina.core.ContainerBase.start(
at org.apache.catalina.core.StandardEngine.start(
at org.apache.catalina.core.StandardService.start(
at org.apache.catalina.core.StandardServer.start(
at org.apache.catalina.startup.Catalina.start(
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(
at org.apache.catalina.startup.Bootstrap.main(
Caused by: java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile
at org.hibernate.ejb.packaging.AbstractJarVisitor.checkAnnotationMatching(
at org.hibernate.ejb.packaging.AbstractJarVisitor.executeJavaElementFilter(
at org.hibernate.ejb.packaging.AbstractJarVisitor.addElement(
at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(
at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(
at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(
at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(
at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(
at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(
at org.hibernate.ejb.packaging.ExplodedJarVisitor.doProcessElements(
at org.hibernate.ejb.packaging.AbstractJarVisitor.getMatchingEntries(
at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(
at org.hibernate.ejb.Ejb3Configuration.scanForClasses(
at org.hibernate.ejb.Ejb3Configuration.configure(
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(
... 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.

Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

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.


Perfect World Programming, LLC - iOS Apps
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: 17410

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:


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:


This is equivalent to putting the same statement in the TOMCAT_HOME/bin/ 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.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: potential eclipse problem
It's not a secret anymore!