Announcement Announcement Module
Collapse
No announcement yet.
getting class not found error with spring 3.2.1 + hibernate 4.x Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • getting class not found error with spring 3.2.1 + hibernate 4.x

    Hi Fellas,

    i am writing a spring portlet which uses hibernate 4.x for the persistence. but when i deploy that into tomcat i am getting the following error. i dont know why it is refering to org.hibernate.util.dtdentity resolver which is hibernate 3.x specific.

    here is my configurations

    Maven POM.

    <dependencies>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-expression</artifactId>
    <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
    <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aop</artifactId>
    <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context-support</artifactId>
    <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-tx</artifactId>
    <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
    <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-orm</artifactId>
    <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-oxm</artifactId>
    <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc-portlet</artifactId>
    <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    <version>${org.springframework.version}</version>
    <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    <version>1.3.170</version>
    </dependency>

    <!-- Hibernate -->

    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.2.0.CR1</version>
    </dependency>

    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>4.2.0.CR1</version>
    </dependency>

    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-ehcache</artifactId>
    <version>4.2.0.CR1</version>
    </dependency>

    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-c3p0</artifactId>
    <version>4.2.0.CR1</version>
    </dependency>

    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-envers</artifactId>
    <version>4.2.0.CR1</version>
    </dependency>

    <dependency>
    <groupId>net.sf.dozer</groupId>
    <artifactId>dozer</artifactId>
    <version>5.4.0</version>
    </dependency>


    <!-- Test -->
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.7</version>
    <scope>test</scope>
    </dependency>
    </dependencies>

    and here is m spring conf

    <contextroperty-placeholder location="/WEB-INF/database.properties" />



    <utilroperties id="hibernateProperties">
    <prop key="hibernate.dialect">org.hibernate.dialect.H2Di alect</prop>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.format_sql">true</prop>
    <prop key="hibernate.order_updates">true</prop>
    <prop key="hibernate.generate_statistics">true</prop>
    <prop key="hibernate.use_sql_comments">true</prop>
    <prop key="hibernate.connection.isolation">2</prop>
    <prop key="hibernate.hbm2ddl.auto">validate</prop>
    </utilroperties>

    <tx:annotation-driven transaction-manager="transactionManager"/>

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

    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate4.LocalSes sionFactoryBean">
    <property name="dataSource" ref="dataSource"></property>
    <property name="annotatedClasses">
    <list>
    <value>com.cisco.prime.dataobject.UserDO</value>
    </list>
    </property>

    </bean>

    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
    destroy-method="close">
    <property name="driverClass" value="${jdbc.driverClassName}" />
    <property name="jdbcUrl" value="${jdbc.url}" />
    <property name="user" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
    <!-- these are C3P0 properties -->
    <property name="acquireIncrement" value="${c3p0.acquireIncrement}" />
    <property name="minPoolSize" value="${c3p0.minPoolSize}" />
    <property name="maxPoolSize" value="${c3p0.maxPoolSize}" />
    <property name="maxIdleTime" value="${c3p0.maxIdleTime}" />
    </bean>

    Error log

    Caused by: java.lang.NoClassDefFoundError: org/hibernate/util/DTDEntityResolver
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader. java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java :615)
    at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:141)
    at org.apache.catalina.loader.WebappClassLoader.findC lassInternal(WebappClassLoader.java:2889)
    at org.apache.catalina.loader.WebappClassLoader.findC lass(WebappClassLoader.java:1170)
    at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1678)
    at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1556)
    at org.hibernate.cfg.Configuration.reset(Configuratio n.java:326)
    at org.hibernate.cfg.Configuration.<init>(Configurati on.java:265)
    at org.hibernate.cfg.Configuration.<init>(Configurati on.java:269)
    at org.springframework.orm.hibernate4.LocalSessionFac toryBuilder.<init>(LocalSessionFactoryBuilder.java :102)
    at org.springframework.orm.hibernate4.LocalSessionFac toryBean.afterPropertiesSet(LocalSessionFactoryBea n.java:259)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1514)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1452)
    ... 65 more

    could u please help me resolving the issue?

  • #2
    Please use [ code][/code ] tags when posting code/xml/stacktraces that way it remains readable ....

    Spring has been tested with hibernate 4.1.x not 4.2 yet... There are probably (again) some internal changes so I suggest sticking with 4.1.x before moving to 4.2 (which hasn't been released you are working with a release candidate and not a final release.)...

    Before switching you might want to make sure you aren't mixing hibernate versions in your classpath (the referenced class appears to be coming from a Hibernate 3.x depedency, so check your dependencies and transitive dependencies using mvn dependency:tree and see where those dependencies come from).
    Last edited by Marten Deinum; Feb 15th, 2013, 03:18 AM.

    Comment

    Working...
    X