aspose file tools*
The moose likes Spring and the fly likes spring + hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "spring + hibernate" Watch "spring + hibernate" New topic
Author

spring + hibernate

bornto pass
Greenhorn

Joined: Jun 23, 2012
Posts: 2
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

Joined: Feb 05, 2001
Posts: 17260
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: spring + hibernate