ClassNotFoundException whereas the JAR is here!


General J2EE: ClassNotFoundException whereas the JAR is here!

  1. 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( ... 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?
  2. Have you included the jars in the Runtime Classpath. i.e. Do you have entries of the spring jar file in your file ?
  3. 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/ 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 Thanks Biswa Das Sun Certified Enterprise Architect