2 Replies Latest reply on Dec 28, 2007 5:54 AM by sarbogast

    ClassNotFoundException whereas the JAR is here!

    sarbogast

      I have a classloading issue with an EAR application. 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:
        <web-app>
        <!-- ... -->
         <listener>
         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
         </listener>
        
         <context-param>
         <param-name>contextConfigLocation</param-name>
         <param-value>
         classpath:applicationContext.xml
         </param-value>
         </context-param>
        </web-app>
        


        And applicationContext.xml (Spring configuration file) resides in myapp-core.jar, with the following section:
        <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
         <property name="dataSource"><ref bean="dataSource"/></property>
         <property name="mappingLocations"><ref bean="hibernateMappingLocations"/></property>
         <property name="hibernateProperties"><ref bean="hibernateProperties"/></property>
         </bean>
        


        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.springframework.orm.hibernate3.LocalSessionFactoryBean] for bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.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?