-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Hibernate + Spring MVC Set Up. Weird Problem
PostPosted: Mon Oct 28, 2013 8:17 pm 
Newbie

Joined: Mon Oct 28, 2013 8:12 pm
Posts: 3
Hello, I'm a first time poster. I was stuck on this weird problem when I'm setting up Hibernate with Spring MVC.

Code:
java.lang.NoClassDefFoundError: org/hibernate/engine/SessionImplementor
   at java.lang.Class.getDeclaredMethods0(Native Method)
   at java.lang.Class.privateGetDeclaredMethods(Class.java:2521)
   at java.lang.Class.getDeclaredMethods(Class.java:1845)
   at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:384)
   at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:322)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:840)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:495)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
   at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
   at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
   at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
   at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
   at java.util.concurrent.FutureTask.run(FutureTask.java:262)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
   at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.ClassNotFoundException: org.hibernate.engine.SessionImplementor
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
   ... 25 more


I am using Hibernate version 4.2.6.FINAL and Spring 3.2.4.RELEASE.

What I figured out that the SessionImplementor location in Hibernate-core.jar is located:
org.hibernate.engine.spi.SessionImplementor and not at org.hibernate.engine.SessionImplementor.

I am still stuck on this problem and I was wondering if someone can help me to relocate to point to the right file.. or do i have to use another version of Hibernate?

Thanks!


Top
 Profile  
 
 Post subject: Re: Hibernate + Spring MVC Set Up. Weird Problem
PostPosted: Tue Oct 29, 2013 4:37 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 18, 2012 5:03 am
Posts: 36
Location: Fort Wayne, Indiana, USA
Can you post your spring bean config file? Are you using the org.springframework.orm.hibernate4.* packages, not hibernate 3?


Top
 Profile  
 
 Post subject: Re: Hibernate + Spring MVC Set Up. Weird Problem
PostPosted: Tue Oct 29, 2013 12:53 pm 
Newbie

Joined: Mon Oct 28, 2013 8:12 pm
Posts: 3
So here is my applicationContext.xml file where I put my spring bean config file, and I am using hibernate4* packages:

Code:
<?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:mvc="http://www.springframework.org/schema/mvc" xmlns:cache="http://www.springframework.org/schema/cache"
   xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p"
   xmlns:c="http://www.springframework.org/schema/c"
   xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
            http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">


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

   <!-- JDBC Data Source. It is assumed you have MySQL running on localhost
      port 3306 with username root and blank password. Change below if it's not
      the case -->
   <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource"
      destroy-method="close">
      <property name="driverClassName" value="com.mysql.jdbc.Driver" />
      <property name="url"
         value="jdbc:mysql://localhost:3306/SQStubbedServices" />
      <property name="username" value="root" />
      <property name="password" value="root" />
      <property name="validationQuery" value="SELECT 1" />
   </bean>

   <!-- Hibernate Session Factory -->
   <bean id="mySessionFactory"
      class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
      <property name="dataSource" ref="myDataSource" />
      <property name="packagesToScan">
         <array>
            <value>com.maker.ice.mockcarrier.model</value>
         </array>
      </property>
      <property name="hibernateProperties">
         <value>
            hibernate.dialect=org.hibernate.dialect.MySQLDialect
         </value>
      </property>
   </bean>

   <!-- Hibernate Transaction Manager -->
   <bean id="transactionManager"
      class="org.springframework.orm.hibernate4.HibernateTransactionManager">
      <property name="sessionFactory" ref="mySessionFactory" />
   </bean>


   <!-- Activates annotation based transaction management -->
   <tx:annotation-driven transaction-manager="transactionManager" />

   <!-- **************************************************************** -->
   <!-- SPRING ANNOTATION PROCESSING -->
   <!-- **************************************************************** -->
   <mvc:annotation-driven />
   <context:component-scan base-package="com.maker.ice" />

</beans>


Top
 Profile  
 
 Post subject: Re: Hibernate + Spring MVC Set Up. Weird Problem
PostPosted: Tue Oct 29, 2013 1:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 18, 2012 5:03 am
Posts: 36
Location: Fort Wayne, Indiana, USA
Are you certain that the ORM 4.2.6.FINAL jar is the only ORM jar on the classpath?


Top
 Profile  
 
 Post subject: Re: Hibernate + Spring MVC Set Up. Weird Problem
PostPosted: Tue Oct 29, 2013 1:48 pm 
Newbie

Joined: Mon Oct 28, 2013 8:12 pm
Posts: 3
I'm pretty certain.. I checked the target class path and src class path and found:

hibernate-commons- annotations- 4.0.2.Final.jar
hibernate-core-4.2.6.Final.jar
hibernate-entitymanager-4.2.6.Final.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar


here is a snippet of my pom.xml file

Code:
      <!-- Servlet API -->
      <dependency>
         <groupId>javax.servlet</groupId>
         <artifactId>javax.servlet-api</artifactId>
         <version>${servlet.version}</version>
         <scope>provided</scope>
      </dependency>

      <dependency>
         <groupId>jstl</groupId>
         <artifactId>jstl</artifactId>
         <version>1.2</version>
      </dependency>
      <dependency>
         <groupId>cglib</groupId>
         <artifactId>cglib</artifactId>
         <version>2.2.2</version>
      </dependency>

      <!-- SPRING -->
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-core</artifactId>
         <version>${springframework.version}</version>
      </dependency>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-web</artifactId>
         <version>${springframework.version}</version>
      </dependency>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-webmvc</artifactId>
         <version>${springframework.version}</version>
      </dependency>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-context-support</artifactId>
         <version>${springframework.version}</version>
      </dependency>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-tx</artifactId>
         <version>${springframework.version}</version>
      </dependency>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-jdbc</artifactId>
         <version>${springframework.version}</version>
      </dependency>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-orm</artifactId>
         <version>${springframework.version}</version>
      </dependency>
      <!-- DB related dependencies -->
      <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-core</artifactId>
         <version>${hibernate.version}</version>
      </dependency>
      <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-entitymanager</artifactId>
         <version>${hibernate.version}</version>
      </dependency>
      <dependency>
         <groupId>mysql</groupId>
         <artifactId>mysql-connector-java</artifactId>
         <version>${mysql.connector.version}</version>
      </dependency>
      <dependency>
         <groupId>commons-dbcp</groupId>
         <artifactId>commons-dbcp</artifactId>
         <version>1.4</version>
      </dependency>

      <!-- Spring Test -->
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-test</artifactId>
         <version>${springframework.version}</version>
         <scope>test</scope>
      </dependency>

      <dependency>
         <groupId>com.google.guava</groupId>
         <artifactId>guava</artifactId>
         <version>${guava.version}</version>
      </dependency>
      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-api</artifactId>
         <version>${slf4j.version}</version>
      </dependency>
      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-log4j12</artifactId>
         <version>${slf4j.version}</version>
      </dependency>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.