Spring-MVC和hibernate:java.lang.NoClassDefFoundError:org / springframework / transaction / interceptor / TransactionInterceptor

时间:2013-01-27 12:29:34

标签: hibernate spring-mvc

我试图使用Spring MVC和Hibernate。我按照本教程操作: http://viralpatel.net/blogs/spring3-mvc-hibernate-maven-tutorial-eclipse-example/

我不是在使用maven,而是使用蚂蚁。我收到此错误:

Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/XXX-servlet.xml] java.lang.NoClassDefFoundError:org/springframework/transaction/interceptor/TransactionInterceptor

我找到了一些类似的线程,其中spring-tx.jar被推荐添加等,但我已经包含了这个。

以下是罐子清单:

  • commons-logging-1.1.1.jar
  • 冬眠核-4.1.9.Final.jar
  • 的JavaEE-API-5.0.4.jar
  • 弹簧AOP-3.2.0.RELEASE.jar
  • 弹簧方面-3.2.0.RELEASE.jar
  • 弹簧豆-3.2.0.RELEASE.jar
  • 弹簧上下文3.2.0.RELEASE.jar
  • 弹簧上下文支持-3.2.0.RELEASE.jar
  • 弹簧芯3.2.0.RELEASE.jar
  • 弹簧表达-3.2.0.RELEASE.jar
  • spring-jdbc-3.2.0.RELEASE.jar
  • 弹簧ORM-3.2.0.RELEASE.jar
  • 弹簧-TX-3.2.0.RELEASE.jar
  • 弹簧网络3.2.0.RELEASE.jar
  • 弹簧webmvc-3.2.0.RELEASE.jar
  • 弹簧webmvc的portlet-3.2.0.RELEASE.jar

我的xxx-servlet.xml:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:lang="http://www.springframework.org/schema/lang"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
        http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">


    <context:annotation-config />
   <context:component-scan base-package="ee.XXX.controller" />

   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="prefix" value="/WEB-INF/jsp/" />
      <property name="suffix" value=".jsp" />
   </bean>

      <bean id="messageSource"
        class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
        <property name="basename" value="classpath:messages" />
        <property name="defaultEncoding" value="UTF-8" />
    </bean>
    <bean id="propertyConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
        p:location="/WEB-INF/jdbc.properties" />

    <bean id="dataSource"
        class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
        p:driverClassName="${jdbc.driverClassName}"
        p:url="${jdbc.databaseurl}" p:username="${jdbc.username}"
        p:password="${jdbc.password}" />

    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="configLocation">
            <value>classpath:hibernate.cfg.xml</value>
        </property>
        <property name="configurationClass">
            <value>org.hibernate.cfg.AnnotationConfiguration</value>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${jdbc.dialect}</prop>
                <prop key="hibernate.show_sql">true</prop>
            </props>
        </property>
    </bean>

    <tx:annotation-driven />
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>

</beans>

我的web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0" metadata-complete="true">
  <display-name>XXX</display-name>
<!--   <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  -->

      <servlet>
        <servlet-name>XXX</servlet-name>
        <servlet-class>
           org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>XXX</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>

任何帮助表示赞赏!

感谢。

0 个答案:

没有答案