복붙노트

[SPRING] java.lang.ClassNotFoundException : org.springframework.orm.hibernate4.LocalSessionFactoryBean

SPRING

java.lang.ClassNotFoundException : org.springframework.orm.hibernate4.LocalSessionFactoryBean

나는 봄에 처음이다. JSF 2, PrimeFaces 3, Spring & Hibernate Integration이다. 다음은 pom.xml입니다.

<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-  
v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MVNO.ONP.project</groupId>
<artifactId>MVNOONPProject</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>MVNOONPProject Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>3.8.1</version>
  <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring</artifactId>
    <version>2.5.6.SEC03</version>
</dependency>
<dependency>
  <groupId>com.sun.faces</groupId>
  <artifactId>jsf-api</artifactId>
  <version>2.1.0-b03</version>
</dependency>
<dependency>
  <groupId>com.sun.faces</groupId>
  <artifactId>jsf-impl</artifactId>
  <version>2.1.0-b03</version>
</dependency>
 <dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>jstl</artifactId>
  <version>1.2</version>
</dependency>
 <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.1.9.Final</version>
 </dependency>

 <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.22</version>
 </dependency>
 </dependencies>
 <build>
  <finalName>MVNOONPProject</finalName>
 </build>
 </project>

프로젝트를 실행할 때이 오류가 발생합니다.

Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.hibernate4.LocalSessionFactoryBean] for bean with name 'SessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.hibernate4.LocalSessionFactoryBean
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1141)
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1105)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:386)
    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.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
    ... 41 more
Caused by: java.lang.ClassNotFoundException: org.springframework.orm.hibernate4.LocalSessionFactoryBean
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:211)
    at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:385)
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1138)
    ... 51 more

해결법

  1. ==============================

    1.Hibernate 4 지원은 3.1의 Spring Framework에 추가되었습니다.

    Hibernate 4 지원은 3.1의 Spring Framework에 추가되었습니다.

    pom.xml은 Spring Framework 2.5.6을 참조하므로 org.springframework.orm.hibernate4.LocalSessionFactoryBean이 존재하지 않습니다. Spring Framework 3.1 또는 이후 버전을 참조하도록 pom.xml을 업데이트해야합니다.

  2. ==============================

    2.마크 덕분에 나는 똑같은 문제를 해결하는 동안

    마크 덕분에 나는 똑같은 문제를 해결하는 동안

    2 당신은 스프링 오름 의존성이 있어야한다. Maven-dependency 이것을 pom.xml에 추가하십시오.

     <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-orm</artifactId>
       <version>4.1.6.RELEASE</version>
    </dependency>
    
  3. ==============================

    3.다음은 스프링 3.1.1을 포함하는 새로운 pom.xml입니다.

    다음은 스프링 3.1.1을 포함하는 새로운 pom.xml입니다.

      <!-- Spring 3 dependencies -->
      <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
       <version>${spring.version}</version>
    </dependency>
    
      <dependency>
      <groupId>org.springframework</groupId>
       <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
      </dependency> 
    
     <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
       <version>${spring.version}</version>
      </dependency>
    
     <dependency>
      <groupId>org.springframework</groupId>
       <artifactId>spring-tx</artifactId>
        <version>${spring.version}</version>
       </dependency>
    
     <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-orm</artifactId>
     <version>${spring.version}</version>
     </dependency>
    
      <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
        </dependency>
    
  4. from https://stackoverflow.com/questions/14548499/java-lang-classnotfoundexception-org-springframework-orm-hibernate4-localsessio by cc-by-sa and MIT license