• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

spring + hibernate

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
https://coderanch.com/t/505963/Spring/Unable-connect-database
but there are only typo mistake

 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic