Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Avinash Ga
Ranch Hand
Posts: 78
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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'
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Avinash Ga
Ranch Hand
Posts: 78
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 78
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic