Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

spring + hibernate

 
bornto pass
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to execute the example from this website: http://www.dzone.com/tutorials/java/spring/spring-hibernate-integration-1.html with postgresql database. but it doesn't work. This is errors:

...................................................
23.06.2012 16:51:29 org.springframework.web.servlet.FrameworkServlet initServletBean
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.hibernate.cfg.AnnotationConfiguration]: Constructor threw exception; nested exception is java.lang.ClassCastException: org.hibernate.annotations.common.reflection.java.JavaReflectionManager cannot be cast to org.hibernate.annotations.common.reflection.MetadataProviderInjector
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1337)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:412)
at java.security.AccessController.doPrivileged(Native Method)
...............................

there are libraries in springhib\WebContent\WEB-INF\lib


i am looking this topic
http://www.coderanch.com/t/505963/Spring/Unable-connect-database
but there are only typo mistake

 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. first off, looking at that tutorial link. I recommend NOT using that tutorial. It looks like a very recent post, and most of it is using recent stuff.

But his Spring MVC is old style, which is NOT recommended to use.

In his code he extends a Spring controller class, this is a really bad design because now your Controller is tightly couple with Spring. Your Controller should be a POJO.

So while I am ok with most of their middle tier code, He uses the term DAO, most Spring people call it a Repository.

But the MVC stuff is NOT TO BE followed. Please try to find another tutorial to follow.

As far as your error, it is a Hibernate error trying to do some cast.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic