cancel
Showing results for 
Search instead for 
Did you mean: 

Spring bean is not udating my database

satyakamkaul
Champ in-the-making
Champ in-the-making
I have an execution listener.
I have loaded a spring bean in the listener. I am calling a function on this bean which eventually updates my database.
But the update does not happen. No sql is generated. This bean method works fine when i call it through my web-application.
I understand its related to transactions and that listener is not in the same context as the spring but i dont know how to fix this. Please help.
Here is my listener.

ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
tkmMgmtService = (TkmMgmtService)context.getBean("tkmMgmtService");
tkmMgmtService.autoCancelProcess(delegateExecution.getProcessInstanceId());
3 REPLIES 3

jbarrez
Star Contributor
Star Contributor
You are creating a new Spring context in the listener? That is definitely not a good thing to do …

You need to make the listener a spring bean, and mark it to be @Transactional.

satyakamkaul
Champ in-the-making
Champ in-the-making
I have declared the listener as a bean in activiti.cfg.xml
and now I am getting my service  bean from the processengine
tkmMgmtService = (TkmMgmtService )Context.getProcessEngineConfiguration().getBeans().get("tkmMgmtService");
Also i have market the bean as @Transactional
but still it does not update the database.
One more thing in the same function i am using runtimeservice to delete the process which is actually updating my activiti database.
But i dont understand why its not updating my non activiti tables

jbarrez
Star Contributor
Star Contributor
mmm it sounds like something is not right. Could you create a simple unit test demonstrating the problem?