General J2EE: ClassNotFoundException whereas the JAR is here!
I have a classloading issue with an EAR application on JBoss 4.2.2. It contains: * spring-2.0.7.jar * myapp-core.jar * myapp-web.war In myapp-web.war, there is a WEB-INF/web.xml file with the following: <!-- ... --> org.springframework.web.context.ContextLoaderListener contextConfigLocation classpath:applicationContext.xml And applicationContext.xml (Spring configuration file) resides in myapp-core.jar, with the following section: Code: And LocalSessionFactoryBean class resides in spring-2.0.7. Yet, when I start up my application, I get the following exception: 19:05:52,534 ERROR [ContextLoader] Context initialization failed org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframewo rk.orm.hibernate3.LocalSessionFactoryBean] for bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.spring framework.orm.hibernate3.LocalSessionFactoryBean Caused by: java.lang.ClassNotFoundException: org.springframework.orm.hibernate3.LocalSessionFactoryBean at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358) ... And I can't figure out why I get this ClassNotFoundException since spring-2.0.7.jar is here, at the root of the EAR. Can somebody help me out with that, because I don't understand how EAR classpath works?
- Posted by: S�bastien Arbogast
- Posted on: December 27 2007 13:29 EST
- Re: ClassNotFoundException whereas the JAR is here! by Krishna Pothula on December 29 2007 11:23 EST
- Re: ClassNotFoundException whereas the JAR is here! by Biswa Das on January 03 2008 20:31 EST
Have you included the jars in the Runtime Classpath. i.e. Do you have entries of the spring jar file in your Manifest.mf file ?
1. If you have only one war file in your ear try to keep your jars in side web-inf/lib. 2. As our friend suggested adding classpath to meta-inf/manifest.mf file in war may solve your problem. But will keep my finger crossed my experience with this try did never work till JBoss 3.2.7 versions how ever containers like weblogic happly accepts this. 3. The other best thing you can try to use Jboss specific classloading mechanism which is not according to standard J2EE classloading approach for that refer to Jboss classloading manual wiki.jboss.org/wiki/Wiki.jsp?page=JBossClassLoadingUseCases Thanks Biswa Das Sun Certified Enterprise Architect