The problem is that you also scan a service and repository packages in your child context. You thus end up with below two instances of each service and repository:
· One in a main context, which is the transactional
· One in a child context, which is not the (since a child context doesn't care about transaction management)
A controller is thus injected with the service coming from a same context as a controller: the not a transactional one.
To confirm that, you should add traces in a constructor of a beans and see how many times they are getting instantiated.
And to avoid a problem, there are below two solutions:
· Avoid the scanning of repository and service packages in a mvc context: this context should only care about the mvc-related beans. When Spring injects the service in the controller, it would thus not find a service in a mvc context, and thus look it up, and find it in a main context. A transactional service would thus be the injected.
· Use the single context: the one of a servlet, where all the beans in a application would be defined.