My @Transactionnal annotations seems to be ignored. I have no errors on the initialization of the Spring container. It looks like my method has not been proxied by Spring TX
You need to define an interface for the @Transactional
annotations to work:
public interface ApplicationsService {
public void createApplication(Application application);
}
And the concrete class:
@Service
public class ApplicationsServiceImpl {
@Transactional
public void createApplication(Application application) {
// ...
}
}
Alternatively, per Kevin Welker's comment, if don't want an interface (though you probably should write an interface), you can configure use proxy-target-class
:
<tx:annotation-driven proxy-target-class="true" />
edit
The message from your SQLException
is:
Field 'status' doesn't have a default value
So maybe you're passing in null
where you should be providing a value? Alternatively, check this post for some weirdness associated with this error.
My guess is that you've put your service beans in the context that belongs to the dispatcher servlet, where only controller beans are supposed to live, and then you've declared your transaction beans in the root context. The annotation-based transaction auto-proxying only applies within a single context, so your service beans in the other (wrong) context won't be affected. See my answer to "Why DispatcherServlet creates another application context?" for a fuller description of the problem. The root problem is that you don't understand how contexts are organized in a Spring MVC application.
After three days of debugging, I finally found the reason why my annotations were ignored.
The <tx:annotation-driven/>
instruction located in a child context file doesn't have access to the beans created by its parent Spring context.
I had to move it to the myapp-servlet.xml
used by my request dispatcher.
Now, it is working properly.