Marcel Wolf
Marcel Wolf

Reputation: 326

Problems With Activiti OSGI and Blueprint

i try to use Activiti in KARAF OSGI with camel.

I copied some parts out of the service mix configuration.

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/blueprint"
       xsi:schemaLocation="
   http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
   http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd"
       xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.0.0"
       xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0"
       xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">

<ext:property-placeholder />

<!--
  Setting up the process engine configuration, using an embedded H2 database together with our default Aries
  transaction manager.
-->
<bean id="dataSource" class="org.h2.jdbcx.JdbcDataSource">
    <property name="URL" value="jdbc:h2:~/activiti"/>
    <property name="user" value="sa"/>
    <property name="password" value=""/>
</bean>

<reference id="transactionManager" interface="javax.transaction.TransactionManager"/>

<bean id="configuration" class="org.activiti.engine.impl.cfg.JtaProcessEngineConfiguration" ext:field-injection="true">
    <property name="databaseType" value="h2"/>
    <property name="dataSource" ref="dataSource"/>
    <property name="transactionManager" ref="transactionManager"/>
    <property name="databaseSchemaUpdate" value="true"/>
    <property name="transactionsExternallyManaged" value="true" />
    <property name="defaultCamelContext" value="defaultContext"/>
</bean>

<!--
  Set up the custom resolver implementation to ease integration with Camel routes
-->
<bean id="resolver" class="de.myproject.CamelAwareELResolver"/>

<reference-list availability="optional" interface="org.activiti.camel.ContextProvider">
    <reference-listener ref="resolver" bind-method="addContextProvider" unbind-method="removeContextProvider" />
</reference-list>

<reference-list availability="optional" interface="org.activiti.engine.delegate.JavaDelegate">
    <reference-listener ref="resolver" bind-method="bindService" unbind-method="unbindService" />
</reference-list>

<!--
  Set up the Activiti process engine itself
-->
<bean id="processEngineFactory" class="org.activiti.osgi.blueprint.ProcessEngineFactoryWithELResolver" init-method="init" destroy-method="destroy">
    <property name="processEngineConfiguration" ref="configuration"/>
    <property name="bundle" ref="blueprintBundle"/>
    <property name="blueprintELResolver" ref="resolver" />
</bean>

<bean id="processEngine" factory-ref="processEngineFactory" factory-method="getObject"/>

<bean id="runtimeService" factory-ref="processEngine" factory-method="getRuntimeService" />

<!--
  Register the ProcessEngine and RuntimeService as OSGi services to allow other bundles to use them
-->
<service ref="processEngine" interface="org.activiti.engine.ProcessEngine"/>
<service ref="runtimeService" interface="org.activiti.engine.RuntimeService"/>


<bean id="routeBuilder" class="de.myproject.bpmn.BpmnRestRouteBuilder"/>

<camelContext id="clientContext" trace="false" xmlns="http://camel.apache.org/schema/blueprint">
    <routeBuilder ref="routeBuilder" />        
    <route id="entryPointClient">
        <from uri="vm:client_queue"/>
        <to uri="jobsbpmn://bpmn"/>
    </route>
</camelContext>

I can deploy the bundle without problems in the container. When i trigger a workflow with a camel module i get those exception:

2016-11-08 11:56:43,569 | ERROR | m://client_queue | JobsBpmnProducer | 45 - jobs-logging - 1.0.0 | No Processdefinition found with this Identifier ActivitiException: Expecting a SpringProcessEngineConfiguration for the Activiti Camel module.
ClassCastException: org.activiti.engine.impl.cfg.JtaProcessEngineConfiguration cannot be cast to org.activiti.spring.SpringProcessEngineConfiguration**

How can i deploy a OSGI conform Processengine using spring to get Camel to work?

Upvotes: 1

Views: 366

Answers (1)

Christian Schneider
Christian Schneider

Reputation: 19626

This problem might be fixed in the Activity code already. See https://github.com/Activiti/Activiti/pull/519

Can you try with the newest Activitiy version?

Upvotes: 0

Related Questions