cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti and Karaf

bkonrad
Champ in-the-making
Champ in-the-making
Activiti 5.16 is now OSGi compatible and Apache Karaf is a great environment to run Activiti. After some time I managed to install the engine as bundles in Apache Karaf.
My first question is: Is there a standard provisioning for installing Activiti in Karaf (i.e. a feature.xml)?

What I did is to implement a bundle exposing activiti services.
My current problem is, that deploying a new process causes that the process image can not be created because of classloader issues:

2014-08-11 10:18:20,041 | WARN  | ExtenderThread-4 | BpmnDeployer                     | 218 - org.activiti.engine - 5.16.0 | Error while generating process diagram, image will not be stored in repository
java.lang.IllegalArgumentException: input == null!
   at javax.imageio.ImageIO.read(ImageIO.java:1348)
   at org.activiti.image.impl.DefaultProcessDiagramCanvas.initialize(DefaultProcessDiagramCanvas.java:218)


Is this a known bug running activiti in OSGi?

This snippet is from bundle exposing activiti as OSGi Services:

        <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
      <property name="dataSource" ref="dataSource" />
      <property name="transactionManager" ref="transactionManager" />
      <property name="databaseSchemaUpdate" value="true" />
      <property name="jobExecutorActivate" value="true" />
      <property name="enableDatabaseEventLogging" value="true" />
      <!– property name="expressionManager" ref="osgiExpressionManager" /–>
   </bean>
   <bean id="processEngineFactory" class="org.activiti.spring.ProcessEngineFactoryBean" destroy-method="destroy">
      <property name="processEngineConfiguration" ref="processEngineConfiguration" />
   </bean>
   <bean id="processEngine" factory-bean="processEngineFactory" factory-method="getObject" />
   <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
   <osgi:service id="repositoryServiceOsgi" ref="repositoryService" interface="org.activiti.engine.RepositoryService" />
   <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
   <osgi:service id="runtimeServiceOsgi" ref="runtimeService" interface="org.activiti.engine.RuntimeService" />

5 REPLIES 5

trademak
Star Contributor
Star Contributor
No there's no standard provisioning in the Activiti project for Karaf. I did create one for my Activiti in Action book though.
The stack trace you included doesn't show classloading issues to me. Or is there more information in the stack trace?

Best  regards,

bkonrad
Champ in-the-making
Champ in-the-making
I took a look into the activiti sources and saw a method in DefaultProcessDiagramCanvas
<code>
public DefaultProcessDiagramCanvas(int width, int height, int minX, int minY, String imageType,
      String activityFontName, String labelFontName, ClassLoader customClassLoader) {

}
</code>
which indicates, that you can use another ClassLoader which breaks OSGi principles 😞

arnoldschrijve1
Champ on-the-rise
Champ on-the-rise
There is this Github project by axemblr: https://github.com/axemblr/activiti-karaf
But it is about 2 years old and targets Activiti 5.10. Upgrading it to newest version and dependencies will require quite a bit of effort.

Also there are issues with Spring 4.x used by the latest Activiti version, which no longer offers native support for OSGi. As an alternative the jars are 'rebundled' by the guys on the Apache ServiceMix project, and a Karaf feature is available to install them: http://repo1.maven.org/maven2/org/apache/karaf/features/spring/3.0.1/spring-3.0.1-features.xml

This feature.xml also contains the spring-dm feature, where the version-range is modified, so Spring 4 is included. But for spring-dm the continued compatibility with new Spring releases is a bit uncertain.

bkonrad
Champ in-the-making
Champ in-the-making
@trademak: Basicly, I did the same as you in the book-osgi-app (I like the idea of deploying seperate process osgi bundles), but the problem of generating the process image is still there. Can you reproduce this issue?
I know the https://github.com/axemblr/activiti-karaf project but is not update-to-date and unnecessary complicated.

bkonrad
Champ in-the-making
Champ in-the-making
I solved the problem by doing some "hacks" - but is there a way to remove the ugly classLoader functionality from org.activiti.image.util.ReflectUtil??

Set the ClassLoader:
<code>
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
  <property name="dataSource" ref="dataSource" />
  <property name="transactionManager" ref="transactionManager" />
  <property name="databaseSchemaUpdate" value="true" />
  <property name="jobExecutorActivate" value="true" />
  <property name="enableDatabaseEventLogging" value="true" />
  <property name="classLoader" ref="classLoader" />
</bean>

<bean id="classLoader" factory-bean="classLoaderFactory" factory-method="getObject" />

<bean id="classLoaderFactory" class="my.ClassLoaderFactoryBean" />
</code>

<code>
public class ClassLoaderFactoryBean implements BundleContextAware {

private BundleContext bundleContext;

public void setBundleContext(BundleContext bundleContext) {
  this.bundleContext = bundleContext;
}

public ClassLoader getObject() {
  Bundle bundle = this.bundleContext.getBundle();
  return bundle.adapt(BundleWiring.class).getClassLoader();
}

}
</code>

Embed the images:
<code>
<Embed-Transitive>true</Embed-Transitive>
<Embed-Dependency>artifactId=activiti-image-generator;inline=org/activiti/icons/**</Embed-Dependency>
</code>