AnsweredAssumed Answered

Activiti within OSGi: Classloader issues after bundle update

Question asked by bpaas on May 4, 2012
Latest reply on May 7, 2012 by bpaas
Hi everyone,

We are building a process-driven web application based on OSGi. We were hoping to make use of OSGi's hot deployment capabilities to update different parts of our system independently without having to restart the server.

Unfortunately, that's when we run into problems. Once we update bundles that are using the engine's functionality, we receive the following errors:
May 03, 2012 9:26:10 AM org.activiti.engine.impl.interceptor.CommandContext close
SEVERE: Error while closing command context
java.lang.ClassCastException: org.activiti.engine.impl.persistence.entity.PropertyEntity cannot be cast to org.activiti.engine.impl.db.PersistentObject
   at org.activiti.engine.impl.db.DbSqlSession.selectById(DbSqlSession.java:217)
   at org.activiti.engine.impl.db.DbSqlSession.dbSchemaUpdate(DbSqlSession.java:629)
   at org.activiti.engine.impl.db.DbSqlSession.performSchemaOperationsProcessEngineBuild(DbSqlSession.java:885)
   at org.activiti.engine.impl.SchemaOperationsProcessEngineBuild.execute(SchemaOperationsProcessEngineBuild.java:25)
   at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.ProcessEngineImpl.<init>(ProcessEngineImpl.java:77)
   at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:271)
   at de.paas.engine.adapter.activiti.ActivitiEngine.initializeEngine(ActivitiEngine.java:53)
   at de.paas.engine.core.ProcessEngineModule.initializeEngine(ProcessEngineModule.java:67)
   at de.paas.engine.core.ProcessEngineModule.<init>(ProcessEngineModule.java:49)
   at de.paas.modelwrapper.Account.findAccount(Account.java:144)
   at de.paas.handler.LoginHandler.post(LoginHandler.java:34)
   at de.paas.dispatcher.LoginDispatcher.doPost(LoginDispatcher.java:56)
   at de.paas.controller.FrontController.startService(FrontController.java:76)
   at de.paas.controller.FrontController.doFilter(FrontController.java:156)
   at de.paas.filter.core.PaasChain.doFilter(PaasChain.java:28)
   at de.paas.filter.PaasMessageFilter.doFilter(PaasMessageFilter.java:46)
   at de.paas.filter.core.PaasChain.doFilter(PaasChain.java:28)
   at de.paas.dispatcher.LoginDispatcher.service(LoginDispatcher.java:40)
   at org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:91)
   at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:110)
   at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
   at org.eclipse.equinox.servletbridge.BridgeServlet.service(BridgeServlet.java:115)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
   at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
   at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
   at java.lang.Thread.run(Thread.java:722)
It was mentioned in another thread in this forum, that the error indicates two classes being loaded by different class loaders and that one could try to explicitly set the classloader for the engine like this:
ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();
processEngineConfiguration.setClassLoader(Thread.currentThread().getContextClassLoader());
Unfortunately, this didn't work for us and the error is still thrown.

I would highly appreciate any comments and advice on this! Thank you in advance,
Johannes

Outcomes