CannotCreateTransactionException Could not open JPA EntityManager

Hi,

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

when the method the follow is execute

rrrrrrr

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!

Hi

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!

method

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!!

ActiveMqListenerPNGActiveMqListenerConfiguracionPNG

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