Java.lang.NoSuchMethodError:org.hibernate.Session

Source: Internet
Author: User

Recently consolidated SPRING4 and Hibernate4,beans.xml are as follows

<?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:context= "Http://www.springframework.org/schema/context"     xmlns:aop= "http// Www.springframework.org/schema/aop "     xmlns:tx=" http://www.springframework.org/ Schema/tx "     xsi:schemalocation=" http://www.springframework.org/schema/beans         http://www.springframework.org/schema/beans/spring-beans.xsd         http://www.springframework.org/schema/context         http://www.springframework.org/schema/context/spring-context.xsd         http://www.springframework.org/schema/aop       http://www.springframework.org/schema/aop/spring-aop.xsd   http://www.springframework.org/schema/tx        http://www.springframework.org/schema/tx/spring-tx.xsd  ">             <context:annotation-config></context: Annotation-config>    <tx:annotation-driven transaction-manager= " TransactionManager "/>    <bean id=" Userdao " class=" Dao.impl.UserDaoImpl " ></bean><bean id= "UserService"  class= "service. UserService "></bean><bean id=" DataSource " class=" Org.apache.commons.dbcp.BasicDataSource ">      <property name=" Driverclassname " value=" Com.mysql.jdbc.Driver "/>      <property name=" url " value=" JDBC: Mysql://localhost:3306/spring "/>      <property name=" username "&Nbsp;value= "root"/>      <property name= "password"  value= " 19870509 "/>   </bean>   <bean id=" TransactionManager "       class= "Org.springframework.orm.hibernate3.HibernateTransactionManager" >       <property name= "Sessionfactory"  ref= "SessionFactory"  />< /bean>  <bean id= "Sessionfactory"  class= " Org.springframework.orm.hibernate4.LocalSessionFactoryBean ">           <property name= "DataSource"  ref= "DataSource"  />           <property name= "Hibernateproperties" >               <props>                    <prop key= "Hibernate.dialect" >org.hibernate.dialect.MySQLDialect</prop>                   <prop key= " Hibernate.show_sql ">true</prop>                 <prop key= "Hibernate.hbm2ddl.auto" >update</prop>                   <prop  key= "Hibernate.format_sql" >true</prop>               </props>          </ Property>         <property name= "AnnotatedClasses" >              <list>        &nBsp;          <value>model. user</value>              </ list>          </property>        </bean>  </beans>

Spring and Hibernate versions are all 4, but the test is reported java.lang.NoSuchMethodError:org.hibernate.Session.openSession () abnormal, and later looked for a long time, It is said that the Hibernate4 version needs Spring4 to support, but mine is 4. Then I began to look at my beans.xml and found that it was wrong here:

<bean id= "TransactionManager" class= "Org.springframework.orm.hibernate3.HibernateTransactionManager" >

Change into

<bean id= "TransactionManager" class= "Org.springframework.orm.hibernate4.HibernateTransactionManager" >

Can.

Java.lang.NoSuchMethodError:org.hibernate.Session

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.