AnsweredAssumed Answered

Running Enterprise Activiti in Websphere AS 7.0

Question asked by ingo_ri on Jun 9, 2011
Latest reply on Nov 22, 2011 by ingo_ri
We have to run the activiti-engine in WebSphere, as like Daniel Meyer does it in JBoss (http://www.bpm-guide.de/2011/05/09/going-java-enterprise-with-activiti-and-jboss-as/). It is important to acces the database through a datasource and to use the transaction management of the app-server.

But Websphere differs from JBoss in accessing the Transaction-Manager. In WebSphere it is impossible to get a reference to the Transaction-Manager with jndi:

"To ensure the integrity of transaction context management (and hence the proper management of transactional resources) WebSphere Application Server does not expose the javax.transaction.TransactionManager interface to applications or application frameworks deployed into WebSphere Application Server." (http://www.ibm.com/developerworks/websphere/techjournal/0609_alcott/0609_alcott.html)

When I use this configuration:

   <!– lookup the JTA-Transaction manager –>
   <bean id="transactionManager" class="org.springframework.jndi.JndiObjectFactoryBean">
      <property name="jndiName" value="java:/TransactionManager"></property>
      <property name="resourceRef" value="true" />
   </bean>

   <!– process engine configuration –>
   <bean id="processEngineConfiguration"
      class="org.activiti.engine.impl.cfg.JtaProcessEngineConfiguration">
      <property name="dataSourceJndiName" value="java:ActivitiDS" />
      <property name="transactionManager" ref="transactionManager" />
      <property name="transactionsExternallyManaged" value="true" />
      <property name="databaseSchemaUpdate" value="drop-create" />
      
      <property name="mailServerHost" value="localhost" />
       <property name="mailServerPort" value="2525" /> 
       
   </bean>
I get this output in the Websphere console:
[06.06.11 13:06:35:858 CEST] 00000020 RemoteExcepti E   CNTR0019E: EJB threw an unexpected (non-declared) exception during invocation of method "startProcessInstanceByKey". Exception data: com.ibm.ejs.container.CreateFailureException: ; nested exception is: 
   org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngineConfiguration' defined in class path resource [activiti.cfg.xml]: Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [activiti.cfg.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name  not found in context "java:".

Caused by: javax.naming.NameNotFoundException: Name  not found in context "java:".
   at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInternal(NameSpace.java:1837)
   at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1166)
   at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:1095)
   at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1233)
   at com.ibm.ws.naming.java.javaURLContextImpl.lookup(javaURLContextImpl.java:394)
   at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:214)
   at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:154)
   at javax.naming.InitialContext.lookup(InitialContext.java:455)
   at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
   at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
   at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)

When I try the Websphere specific TransactionManager for Spring, it's this configuration:

   <bean id="transactionManager"
      class="org.springframework.transaction.jta.WebSphereUowTransactionManager"/>

   <!– process engine configuration –>
   <bean id="processEngineConfiguration"
      class="org.activiti.engine.impl.cfg.JtaProcessEngineConfiguration">
      <property name="dataSourceJndiName" value="jdbc/activitiDSH2" />
      <property name="transactionManager" ref="transactionManager" />
      <property name="transactionsExternallyManaged" value="true" />
      <property name="databaseSchemaUpdate" value="false" />
      
      <property name="mailServerHost" value="localhost" />
       <property name="mailServerPort" value="2525" /> 
       
   </bean>
And I get this output:
[06.06.11 13:12:20:699 CEST] 00000020 XmlBeanDefini I org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions Loading XML bean definitions from class path resource [activiti.cfg.xml]
[06.06.11 13:12:20:840 CEST] 00000020 ProcessEngine I   Activiti service  failed to initialize, see above.
[06.06.11 13:12:20:840 CEST] 00000020 RemoteExcepti E   CNTR0019E: EJB threw an unexpected (non-declared) exception during invocation of method "startProcessInstanceByKey". Exception data: com.ibm.ejs.container.CreateFailureException: ; nested exception is:
   org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngineConfiguration' defined in class path resource [activiti.cfg.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.springframework.transaction.jta.WebSphereUowTransactionManager' to required type 'javax.transaction.TransactionManager' for property 'transactionManager'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.transaction.jta.WebSphereUowTransactionManager] to required type [javax.transaction.TransactionManager] for property 'transactionManager': no matching editors or conversion strategy found
   at com.ibm.ejs.container.StatelessBeanO.initialize(StatelessBeanO.java:404)

Caused by: java.lang.IllegalStateException: Cannot convert value of type [org.springframework.transaction.jta.WebSphereUowTransactionManager] to required type [javax.transaction.TransactionManager] for property 'transactionManager': no matching editors or conversion strategy found
   at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:289)
   at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:154)
   at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:452)
   … 69 more


What kind of configuration of the spring-beans would you suggest to re-use the transactions from websphere?


Thanks and Kind Regards,

Ingo

Outcomes