CannotCreateTransactionException Could not open JPA EntityManager


I get the wrong org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager

when the method the follow is execute


Is there any way to execute the bean when the EntityManager will be open JPA EntityManager???. . … something with the annotation @DependsOn, I couldn´t solve the problem!

thank a lot!


You are trying to use persistence before the container is initialized. It won’t work.

Is there any way to execute automatically this method just after the application will be start and persistence will be available? thank a lot!


Sure. Subscribe to AppContextStartedEvent.

In the follow class “ActivemqMessageListener”, I try to use a listener with activeMq ,. . . . do you know why Persistence = null in the method onMessage ??? . . do you know how I could solve the problem?
I attach the classes “ActivemqMessageListener” and the config “ActiveMqConfig”… . thank a lot!!


It’s hard to decide from screenshots.
We can look into the problem if you provide a small test project demonstrating it.