简体   繁体   English

找到NoClassDefinitionFoundError javax / transaction / TransactionManager

[英]NoClassDefinitionFoundError foundjavax/transaction/TransactionManager

Hi everyone I am getting problem while I am trying to integrate spring 3.0 with hibernate 3.1, why I am getting this type of error. 大家好,我在尝试将Spring 3.0与Hibernate 3.1集成时遇到问题,为什么会出现这种错误。 In "HibernateDAO" class I just used "autowired" technique for "HibernateTemplate" and its throwing error... I am enclosing "applicationcontext" and "web.xml" 在“ HibernateDAO”类中,我仅对“ HibernateTemplate”使用了“自动装配”技术,并且抛出了错误……我将“ applicationcontext”和“ web.xml”包含在内

 applicationContext:@

    <?xml version="1.0" encoding="UTF-8"?>
       <beans 
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:aop="http://www.springframework.org/schema/aop"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation=
   "http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/mvc
     http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
     http://www.springframework.org/schema/aop
     http://www.springframework.org/schema/aop/spring-aop-3.0.xsd" > 

   <!--<context:annotation-config />-->

   <mvc:annotation-driven/>
   <context:component-scan base-package="com.spring" />

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


   <bean id="bs" class="com.spring.BookServiceImpl"  />

    <bean id="hbdao" class="com.spring.HibernateBookDAO"  />

    <bean id="htemp" class="org.springframework.orm.hibernate3.HibernateTemplate"  autowire="constructor" />

    <!--<bean id="txManger"     class="org.springframework.orm.hibernate3.TransactionManager" autowire="byName" />-->

    <!--<bean id="transactionManager" class="org.springframework.orm.hibernate.Hibernate TransactionManager">
   <property name="sessionFactory">
    <ref bean="sessionFactory"/>
   </property>
  </bean>
     -->

   <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />

    <property name="hibernateProperties">
    <map>
    <entry key="hibernate.dialect"    value="org.hibernate.dialect.MySQLDialect" />
    <entry key="hibernate.show_sql" value="true" />
    <entry key="hibernate.hbm2ddl.auto" value="update" />
    </map>
    </property>

    <property name="mappingResources">
    <list>
    <value>com/spring/book.hbm.xml</value>
    </list>
    </property>

    </bean>


 <bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName"
        value="com.mysql.jdbc.Driver">
    </property>
    <property name="url"
        value="jdbc:mysql://loacalhost:3306/napiertest">
    </property>
    <property name="username" value="root"></property>
    <property name="password" value="napier"></property>
    </bean>

    </beans>

web.xml :@ web.xml:@

  <?xml version="1.0" encoding="UTF-8"?>
 <web-app version="3.0" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
 <display-name></display-name>  
 <welcome-file-list>
 <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>

 <servlet>
 <servlet-name>applicationContext</servlet-name>
 <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-  class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
     </servlet>

   <servlet-mapping>
   <servlet-name>applicationContext</servlet-name>
       <url-pattern>*.do</url-pattern>
       </servlet-mapping>

      </web-app>

In your case, Your applicationContext Dispatcher servlet having *.do extension. 在您的情况下,您的applicationContext Dispatcher servlet具有* .do扩展名。

<servlet-mapping>
   <servlet-name>applicationContext</servlet-name>
       <url-pattern>*.do</url-pattern>
</servlet-mapping>

Change your controller like this.. Your RequestMapping should have .do extension. 像这样更改您的控制器。您的RequestMapping应该具有.do扩展名。 Requests are coming from web.xml with .do extension, the requests should match with your controller @RequestMapping annotation. 请求来自带有.do扩展名的web.xml,请求应与您的控制器@RequestMapping注释匹配。 So add like this, 所以添加这样,

@Controller
@RequestMapping("/")
public class AppController {

@RequestMapping(value="/home.do" method=RequestMethod.GET)
    public String SampleMethod(Model model){

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 引起:java.lang.NoClassDefFoundError: Ljavax/transaction/TransactionManager; - Caused by: java.lang.NoClassDefFoundError: Ljavax/transaction/TransactionManager; 无法查找JNDI名称[javax.transaction.TransactionManager] - Unable to lookup JNDI name [javax.transaction.TransactionManager] 无法访问TransactionManager或UserTransaction以进行物理事务委托 - Unable to access TransactionManager or UserTransaction to make physical transaction delegate Hibernate:无法访问TransactionManager或UserTransaction以进行物理事务委托 - Hibernate: Unable to access TransactionManager or UserTransaction to make physical transaction delegate Spring事务管理:无法解析bean&#39;transactionManager&#39;的引用 - Spring transaction management: Cannot resolve reference to bean 'transactionManager' Infinispan事务-无法从Spring4获取TransactionManager - Infinispan transaction - can not get TransactionManager from Spring4 Java-Java类的NoClassDefinitionFoundError - Java - NoClassDefinitionFoundError for Java Class 在事务提交后使用 spring transactionManager 和 Hibernate 实际上只提交了两个存储库 - using spring transactionManager with Hibernate after transaction committed only one repository of two is actually being committed 当 transactionManager 未命名为“transactionManager”时 - When transactionManager is not named "transactionManager" Quarkus Hibernate 找不到所需类型 [接口 javax.transaction.TransactionManager] 和限定符 [[]] 的 bean - Quarkus Hibernate No bean found for required type [interface javax.transaction.TransactionManager] and qualifiers [[]]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM