AnsweredAssumed Answered

Stuck at SpringTransactionInterceptor execute !

Question asked by ssun on Jun 12, 2014
Latest reply on Jun 30, 2014 by trademak
This is a bit of long story so please bear with me for a minute:

We are using mysql database as the backend.
We are using the out of the box activiti-explorer.war and activiti-rest.war
We put them in an apache tomcat instance and we modified and pointed them to the mysql database.
For the explorer we use LDAP for authentication.
We log on through the explorer and deploy our workflow definitions using the UI.
For the rest api, we do not user LDAP but created a username + password.
We have this set of username + password in our code and our code use the REST api to start process instances, complete tasks, etc.
Most of our workflows does not do the heavy lifting work. They simply sit there and the other piece of code we have will tell workflow what happened. The workflows have timers and if task did not finish in time, they will send alert emails.

After running happily for several days, we suddenly cannot login through the explorer.
The rest API has no problem at all and no performance problem.
Absolutely nothing changed during that time except we accumulated some processes and tasks (about 8000).

At first, I thought this is a problem with the explorer, so I posted this
But after so many hours of trying different things, I believe this is likely very related to the engine itself so I'm moving the question here.

Here are my findings:

1. We can see the login screen with no problem but after type in username and password, it stuck and never return.
2. There are no logs at all in the apache. Basically a thread went working and never returned.
3. If I use the rest API to close all the tasks, then if I restart the server, I can log in. If I do not restart the server, I cannot.
4. I do not have to close all the tasks. I can close some of them and restart and works. I cannot tell if there are particular tasks problematic. I would hope the service be more resilient.
5. I also tested with switched the backend database back and forth with a previous working snapshot of the database. It works every time, so it is related to the data.
6. Something is wrong from the beginning when the activiti-explorer app starts. Once it is started I cannot stop the service properly using apache's script. I have to use "kill -9". Some threads are stuck from the beginning.
7. I started to spend hours compile activiti from source code and try to add loggings to try to figure out the problem. I found the problematic line is:

I added some print statements:
    System.out.println("ssun: SpringTransactionInterceptor execute 4");
    T result = transactionTemplate.execute(new TransactionCallback<T>() {
      public T doInTransaction(TransactionStatus status) {
         System.out.println("ssun: TransactionCallback doInTransaction 1");
        T result = next.execute(config, command);
        System.out.println("ssun: TransactionCallback doInTransaction 2");
        return result;
    System.out.println("ssun: SpringTransactionInterceptor execute 5");

And when I use the working database, I see:
ssun: SpringTransactionInterceptor execute 1
ssun: SpringTransactionInterceptor execute 2
ssun: SpringTransactionInterceptor execute 3
ssun: SpringTransactionInterceptor execute 4
ssun: TransactionCallback doInTransaction 1
ssun: TransactionCallback doInTransaction 2
ssun: SpringTransactionInterceptor execute 5

When I use the non-working database, I see:
ssun: SpringTransactionInterceptor execute 1
ssun: SpringTransactionInterceptor execute 2
ssun: SpringTransactionInterceptor execute 3
ssun: SpringTransactionInterceptor execute 4

It's clearly stuck here. But from there, it is spring code. I really don't know what can I do. How can my data in my database impact how the code?
And I do not only see this when I try to login from the explorer, I see them during start up which confirms my feeling that some threads got stuck from the beginning.

Also here is the stack trace I printed out at the stucking point when I try to login:

ssun: authenticate 1
ssun: checkPassword 1
ssun: CommandExecutorImpl.execute 1
class org.activiti.engine.impl.interceptor.LogInterceptor
ssun: LogInterceptor.execute 1
ssun: LogInterceptor.execute 2
class org.activiti.spring.SpringTransactionInterceptor
ssun: SpringTransactionInterceptor execute 1
ssun: SpringTransactionInterceptor execute 2
ssun: SpringTransactionInterceptor execute 3
ssun: SpringTransactionInterceptor execute 4
   at org.activiti.spring.SpringTransactionInterceptor.execute(
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(
   at org.activiti.engine.impl.IdentityServiceImpl.checkPassword(
   at org.activiti.explorer.ui.login.DefaultLoginHandler.authenticate(
   at org.activiti.explorer.ui.login.DefaultLoginHandler.authenticate(
   at org.activiti.explorer.ui.login.LoginPage$ActivitiLoginListener.onLogin(
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(
   at java.lang.reflect.Method.invoke(
   at com.vaadin.event.ListenerMethod.receiveEvent(
   at com.vaadin.event.EventRouter.fireEvent(
   at com.vaadin.ui.AbstractComponent.fireEvent(
   at com.vaadin.ui.LoginForm$2.handleParameters(
   at com.vaadin.ui.Window.handleParameters(
   at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(
   at javax.servlet.http.HttpServlet.service(
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(
   at org.apache.tomcat.websocket.server.WsFilter.doFilter(
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(
   at org.activiti.explorer.filter.ExplorerFilter.doFilter(
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(
   at org.apache.catalina.core.StandardWrapperValve.invoke(
   at org.apache.catalina.core.StandardContextValve.invoke(
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
   at org.apache.catalina.core.StandardHostValve.invoke(
   at org.apache.catalina.valves.ErrorReportValve.invoke(
   at org.apache.catalina.valves.AccessLogValve.invoke(
   at org.apache.catalina.core.StandardEngineValve.invoke(
   at org.apache.catalina.connector.CoyoteAdapter.service(
   at org.apache.coyote.http11.AbstractHttp11Processor.process(
   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
   at java.util.concurrent.ThreadPoolExecutor.runWorker(
   at java.util.concurrent.ThreadPoolExecutor$

Any thoughts would help! Thank you in advance!