Hello. I try manage transactions with Spring.
This is my applicationContext.xml:
When I try to run my web application, I get an error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed;
nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'txAdvice': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager';
nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed;
nested exception
is org.hibernate.service.UnknownUnwrapTypeException: Cannot unwrap to requested type [javax.sql.DataSource]
Well, first I recommend using the @Transactional annotation in your code instead of the verbose xml style of Transaction configuration.
Also, it looks to me that it probably is in your hibernate.cfg.xml file. That it doesn't have a DataSource configured in that file.
I also recommend no longer using a hibernate.cfg.xml file and put the configuration in your Spring configuration, which includes defining a bean for your DataSource.
Mark Spritzler wrote:Well, first I recommend using the @Transactional annotation in your code instead of the verbose xml style of Transaction configuration.
Also, it looks to me that it probably is in your hibernate.cfg.xml file. That it doesn't have a DataSource configured in that file.
I also recommend no longer using a hibernate.cfg.xml file and put the configuration in your Spring configuration, which includes defining a bean for your DataSource.
Mark
You are right, now, when I have DataSource, apllication running well. Thanks.
One more question. What have I write to Spring configuration instead
I recommend looked at the Spring documentation for an example. But off the top of my head what I put is almost correct, or it might be correct. I don't memorize that stuff.
Good Luck
Mark
subject: Spring, Hibernate, transaction Management | Cannot unwrap to requested type