*
The moose likes Spring and the fly likes whats wrong with my spring 3.x + hibernate 4.x + maven configuration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "whats wrong with my spring 3.x + hibernate 4.x + maven configuration" Watch "whats wrong with my spring 3.x + hibernate 4.x + maven configuration" New topic
Author

whats wrong with my spring 3.x + hibernate 4.x + maven configuration

Avinash Ga
Ranch Hand

Joined: Aug 13, 2011
Posts: 78

Hi Ranchers,

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.

here is my configurations

Maven POM.



Spring COnf......



error says......

aused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring/databaseContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/util/DTDEntityResolver
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
... 55 more
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(SecureClassLoader.java:141)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2889)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1170)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
at org.hibernate.cfg.Configuration.reset(Configuration.java:326)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:265)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:269)
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.<init>(LocalSessionFactoryBuilder.java:102)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:259)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 65 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.util.DTDEntityResolver
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
... 80 more
Feb 14, 2013 9:19:50 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Feb 14, 2013 9:19:50 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/Signup-1.0.0-BUILD-SNAPSHOT] startup failed due to previous errors
Feb 14, 2013 9:19:50 AM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
09:19:50,144 INFO [pool-2-thread-8][PluginPackageUtil:1033] Reading plugin package for Signup-1.0.0-BUILD-SNAPSHOT
09:19:50,144 WARN [pool-2-thread-8][PluginPackageUtil:1131] Plugin package on context Signup-1.0.0-BUILD-SNAPSHOT cannot be tracked because this WAR does not contain a liferay-plugin-package.xml file
Feb 14, 2013 9:19:50 AM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
INFO : org.springframework.web.portlet.DispatcherPortlet - Initializing portlet 'Signup'

Avinash G.A
OCP Java SE 6 Programmer, OCP Java EE 5 Web Component Developer, OCE Java EE 6 Web Services Developer, VMware Certified Core Spring 3.x Developer, EMC Proven Professional (ISM-V2)
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Based on my Google search. That class looks to be in Hibernate 3 and not in Hibernate 4.

So that tells me that somewhere, somehow, one of the depenencies is bringing in Hibernate 3.

Have you tried running maven's command for showing dependencies, or through your IDE

I think it is something like

mvn dependency:tree

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Avinash Ga
Ranch Hand

Joined: Aug 13, 2011
Posts: 78

Yes, exactly that is the problem...... here is my dependency tree, in this it is nowhere mentioned the dependency on hibernate 3.x...... I dont know why my org.springframework.orm.hibernate4.LocalSessionFactoryBean initialize method refering to that......... may be some bug in spring..... will try to post my issue in springsource community......

Thanks Mark

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Signup 1.0.0-BUILD-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ Signup ---
[INFO] com.cisco.prime:Signup:war:1.0.0-BUILD-SNAPSHOT
[INFO] +- org.springframework:spring-core:jar:3.2.1.RELEASE:compile
[INFO] +- org.springframework:spring-expression:jar:3.2.1.RELEASE:compile
[INFO] +- org.springframework:spring-beans:jar:3.2.1.RELEASE:compile
[INFO] +- org.springframework:spring-aop:jar:3.2.1.RELEASE:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-context:jar:3.2.1.RELEASE:compile
[INFO] +- org.springframework:spring-context-support:jar:3.2.1.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:3.2.1.RELEASE:compile
[INFO] +- org.springframework:spring-jdbc:jar:3.2.1.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:3.2.1.RELEASE:compile
[INFO] +- org.springframework:spring-oxm:jar:3.2.1.RELEASE:compile
[INFO] | \- commons-lang:commons-lang:jar:2.5:compile
[INFO] +- org.springframework:spring-web:jar:3.2.1.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:3.2.1.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc-portlet:jar:3.2.1.RELEASE:compile
[INFO] +- org.springframework:spring-test:jar:3.2.1.RELEASE:test
[INFO] +- org.aspectj:aspectjrt:jar:1.6.10:compile
[INFO] +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.6.6:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.6.6:runtime (scope not updated to compile)
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.6:runtime (scope not updated to compile)
[INFO] +- log4j:log4j:jar:1.2.15:runtime
[INFO] +- javax.inject:javax.inject:jar:1:compile
[INFO] +- com.liferay.portal:portal-service:jar:6.1.1:provided
[INFO] +- com.liferay.portal:util-bridges:jar:6.1.1:provided
[INFO] +- com.liferay.portal:util-taglib:jar:6.1.1:provided
[INFO] +- com.liferay.portal:util-java:jar:6.1.1:provided
[INFO] +- javax.portlet:portlet-api:jar:2.0:provided
[INFO] +- com.sun.portal.portletcontainer:portlettaglib:jar:2.0-m1:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided
[INFO] +- javax.servlet.jsp:jsp-api:jar:2.1:provided
[INFO] +- javax.servlet:jstl:jar:1.2:compile
[INFO] +- org.hibernate:hibernate-core:jar:4.2.0.CR1:compile
[INFO] | +- antlr:antlr:jar:2.7.7:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.1.0.GA:compile
[INFO] | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.0.Final:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
[INFO] | +- org.javassist:javassist:jar:3.15.0-GA:compile
[INFO] | \- org.hibernate.common:hibernate-commons-annotations:jar:4.0.1.Final:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:4.2.0.CR1:compile
[INFO] +- org.hibernate:hibernate-ehcache:jar:4.2.0.CR1:compile
[INFO] | \- net.sf.ehcache:ehcache-core:jar:2.4.3:compile
[INFO] +- org.hibernate:hibernate-c3p0:jar:4.2.0.CR1:compile
[INFO] | \- c3p0:c3p0:jar:0.9.1:compile
[INFO] +- org.hibernate:hibernate-envers:jar:4.2.0.CR1:compile
[INFO] +- com.h2database:h2:jar:1.3.170:compile
[INFO] +- net.sf.dozer:dozer:jar:5.4.0:compile
[INFO] | +- commons-beanutils:commons-beanutils:jar:1.8.3:compile
[INFO] | \- org.apache.commons:commons-lang3:jar:3.1:compile
[INFO] \- junit:junit:jar:4.7:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
viapro young
Greenhorn

Joined: Aug 20, 2013
Posts: 1
Is it sovled? I think I've got the same problem

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(SecureClassLoader.java:141)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2895)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.hibernate.cfg.Configuration.reset(Configuration.java:336)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:275)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:279)
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.<init>(LocalSessionFactoryBuilder.java:106)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:278)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
... 39 more
Avinash Ga
Ranch Hand

Joined: Aug 13, 2011
Posts: 78

viapro young wrote:Is it sovled? I think I've got the same problem

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(SecureClassLoader.java:141)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2895)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.hibernate.cfg.Configuration.reset(Configuration.java:336)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:275)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:279)
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.<init>(LocalSessionFactoryBuilder.java:106)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:278)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
... 39 more



No i was unable to overcome this. It will help if you pin point the exact location. Didnt find any clue in the code.
 
wood burning stoves
 
subject: whats wrong with my spring 3.x + hibernate 4.x + maven configuration
 
Similar Threads
Spring Major version '3' expected
Maven web project dependencies
Could not resolve dependencies for maven project
Maven dependencies
Incorrect hibernate version or maven ignore and didn't download hibernate jar file.