Activiti OSGI和蓝图的问题

时间:2016-11-08 11:03:37

标签: apache-camel osgi activiti apache-karaf blueprint-osgi

我尝试在骆驼的KARAF OSGI中使用Activiti。

我从服务组合配置中复制了一些部分。

<?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>

我可以在容器中部署捆绑包而不会出现问题。当我使用camel模块触发工作流程时,我得到了这些例外:

  

2016-11-08 11:56:43,469 |错误| m:// client_queue | JobsBpmnProducer   | 45 - jobs-logging - 1.0.0 |没有找到Processdefinition   Identifier ActivitiException:期待a   Activiti Camel模块的SpringProcessEngineConfiguration   ClassCastException异常:   org.activiti.engine.impl.cfg.JtaProcessEngineConfiguration不能   强制转换为org.activiti.spring.SpringProcessEngineConfiguration **

如何使用spring部署符合OSGI的Processengine以使Camel工作?

1 个答案:

答案 0 :(得分:0)

此问题可能已在活动代码中修复。 见https://github.com/Activiti/Activiti/pull/519

您可以尝试使用最新的Activitiy版本吗?