Hibernate and Spring3 Transaction Management Annotation-Configuration problems: Hibernate-Exception: No Hibernate Session bound to thread?

Your service method isn't being wrapped in a transaction. You can tell from the stack trace. There should be several stack frames related to transactions and proxying between your controller and service.

What is "HomeController", and how does it get the instance of UserService that it uses? The tx:annotation-driven tag/bean should occur in the same ApplicationContext where your @Transactional beans are defined, and that appears to be in your servlet-context. Xml, so that should be fine.

Your service method isn't being wrapped in a transaction. You can tell from the stack trace. There should be several stack frames related to transactions and proxying between your controller and service.

What is "HomeController", and how does it get the instance of UserService that it uses? The tag/bean should occur in the same ApplicationContext where your @Transactional beans are defined, and that appears to be in your servlet-context. Xml, so that should be fine.

Thanks, I added the HomeController source to the question. The UserService is autowired and should be filled in via Spring. The HomeController is the controller-class that is used by spring-mvc.

I know that the transactions are missing, but I could not figure out how to configure Spring to notice the annoations. – Michael Helwig Jul 17 at 16:21 @Michael: I'm glad you found a solution. I didn't have time to get to it before, but I've got an executable example of using the @Transactional annotation that's based mostly on the code you posted.

There must have been something strange somewhere that you didn't post because what you gave me pretty much worked all on its own. To check out the example: git clone git@github. Com:zzantozz/testbed tmp;cd tmp/basic-springmvc;mvn jetty:run.

Then go to locahost:8080 and click the link. You'll see that it all works. If you compare it to what you had, maybe you can find what was wrong.

– Ryan Stewart Jul 19 at 22:29 1 @Michael: Oh, you really need to move your hibernate.cfg. Xml and jdbc. Properties out of src/main/webapp.

If you leave them there, they'll be publicly available resources. Try putting them in src/main/resources instead and referring to them with a "classpath:" prefix. – Ryan Stewart Jul 19 at 22:31 Thanks very much for your hints, I appreciate this.

I tried to check out your project but got an "access denied" error. I cannot think of stuff that I missed to post here (besides db credentials) - perhaps it has something to do with using VMware server that comes with STS but I'm not sure about that. – Michael Helwig Jul 23 at 19:40 Sorry, I gave you the read/write url instead of the anonymous access one.

If you still want to take a look at it: git clone git://github. Com/zzantozz/testbed. Git tmp;cd tmp/basic-springmvc;mvn jetty:run – Ryan Stewart Jul 25 at 16:36.

I finally think I got what I wanted: Automatic transaction management. After reading about Springs Declarative Transaction Management and adding an AOP Proxy, I got it working. I added the following code to my servlet-context.

Xml and everything went fine: Probably it needs some finetuning but for now it works! @Ryan: Thanks for pointing me to transaction management!

I finally think I got what I wanted: Automatic transaction management. After reading about Springs Declarative Transaction Management and adding an AOP Proxy, I got it working. I added the following code to my servlet-context.

Xml and everything went fine.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions