Spring Framework
  1. Spring Framework
  2. SPR-8776

java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Complete
    • Affects Version/s: 3.1 RC1
    • Fix Version/s: 3.1 RC2
    • Component/s: Core
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      Hi when i ran a unit test with hibernate 4 i get this error.

      java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;
      at org.springframework.orm.hibernate4.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:328)
      at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
      at org.springframework.test.context.transaction.TransactionalTestExecutionListener$TransactionContext.startTransaction(TransactionalTestExecutionListener.java:513)
      at org.springframework.test.context.transaction.TransactionalTestExecutionListener.startNewTransaction(TransactionalTestExecutionListener.java:271)
      at org.springframework.test.context.transaction.TransactionalTestExecutionListener.beforeTestMethod(TransactionalTestExecutionListener.java:164)
      at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:358)
      at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:73)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
      at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
      at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
      at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
      at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
      at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:119)
      at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:101)

      Here is my xml configuration:
      <bean id="sessionFactory"
      class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
      <property name="dataSource" ref="coreDataSource" />
      <property name="configLocation" value="classpath:hibernate.cfg.xml" />
      <property name="hibernateProperties" ref="hibernateProperties" />
      <property name="packagesToScan" value="com.user.domain" />
      </bean>

      <bean id="transactionManager"
      class="org.springframework.orm.hibernate4.HibernateTransactionManager">
      <property name="sessionFactory" ref="sessionFactory" />
      </bean>

        Issue Links

          Activity

          Hide
          Juergen Hoeller added a comment -

          Good catch! This is caused by signature differences between Hibernate 3.x and Hibernate 4.x which we have to bridge in our cross-compilation scenario. Fixed for 3.1 RC2.

          Juergen

          Show
          Juergen Hoeller added a comment - Good catch! This is caused by signature differences between Hibernate 3.x and Hibernate 4.x which we have to bridge in our cross-compilation scenario. Fixed for 3.1 RC2. Juergen
          Hide
          John Kroubalkian added a comment -

          We have the situation described here (java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session.

          I took Juergen's changes (6 classes) and deployed them in my project. All works well.

          Q: What is the best way to keep local code up to date with related RC2 changes?

          Q: Where to pull source for RC2?

          Q: How to build source for RC2?

          Q: Will multiple .jar(s) need building and deployment?

          Q: When is RC2 scheduled for general availability?

          Thanks

          Show
          John Kroubalkian added a comment - We have the situation described here (java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session . I took Juergen's changes (6 classes) and deployed them in my project. All works well. Q: What is the best way to keep local code up to date with related RC2 changes? Q: Where to pull source for RC2? Q: How to build source for RC2? Q: Will multiple .jar(s) need building and deployment? Q: When is RC2 scheduled for general availability? Thanks
          Hide
          Chris Beams added a comment -

          Q: What is the best way to keep local code up to date with related RC2 changes?

          Assuming you use Maven, add the following to your POM:

          <repository>
              <id>spring-snapshot</id>
              <url>http://maven.springframework.org/snapshot</url>
          </repository>
          ...
          <dependency>
           <groupId>org.springframework</groupId>
           <artifactId>spring-orm</artifactId>
           <version>3.1.0.BUILD-SNAPSHOT</version>
          </dependency> 
          

          Q: Where to pull source for RC2?

          svn checkout https://src.springframework.org/svn/spring-framework/trunk spring-framework
          

          Q: How to build source for RC2?

          http://blog.springsource.org/2009/03/03/building-spring-3

          Q: When is RC2 scheduled for general availability?

          Shortly. Within the next 1-2 weeks.

          Show
          Chris Beams added a comment - Q: What is the best way to keep local code up to date with related RC2 changes? Assuming you use Maven, add the following to your POM: <repository> <id>spring-snapshot</id> <url>http: //maven.springframework.org/snapshot</url> </repository> ... <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>3.1.0.BUILD-SNAPSHOT</version> </dependency> Q: Where to pull source for RC2? svn checkout https://src.springframework.org/svn/spring-framework/trunk spring-framework Q: How to build source for RC2? http://blog.springsource.org/2009/03/03/building-spring-3 Q: When is RC2 scheduled for general availability? Shortly. Within the next 1-2 weeks.
          Hide
          Crummy Nickname added a comment -

          How do we download a zip file of all spring artifacts form RC2 ? Thanks

          Show
          Crummy Nickname added a comment - How do we download a zip file of all spring artifacts form RC2 ? Thanks
          Show
          John Kroubalkian added a comment - @Chris Thanks for the responses. I see RC2 is out! Great news: http://www.springsource.com/download/community http://s3.amazonaws.com/dist.springframework.org/milestone/SPR/spring-framework-3.1.0.RC2-with-docs.zip http://s3.amazonaws.com/dist.springframework.org/milestone/SPR/spring-framework-3.1.0.RC2.zip

            People

            • Assignee:
              Juergen Hoeller
              Reporter:
              chun ping wang
              Last updater:
              Trevor Marshall
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                2 years, 21 weeks ago