lundi 22 avril 2013

Setting up Activiti-CDI

If you follow the 'offical' user guide

http://www.activiti.org/userguide/#cdiintegration

You may be stuck on the following issue
org.activiti.engine.ActivitiException: Could not find an implementation of the org.activiti.cdi.spi.ProcessEngineLookup service returning a non-null processEngine. Giving up. at org.activiti.cdi.impl.ActivitiExtension.lookupProcessEngine(ActivitiExtension.java:106) at org.activiti.cdi.impl.ActivitiExtension.afterDeploymentValidation(ActivitiExtension.java:68)
And find many friends on the Internet with posts describing the same issue :

http://forums.activiti.org/content/activiti-cdi-exception
http://forums.activiti.org/content/issue-activiti-cdi-libraries

So we not just feeling alone; that is a good point ;)

Actually you may produce the Activiti Engine instance with a 'programatic' CDI OR a Spring activiti.cfg.xml. 
This is the complete JBoss setup on BitBucket :

https://bitbucket.org/meyerd/activiti-cdi-jbossas7.1.1-setup

The activiti user guide doesn't not explain clearly the two possibilities. Here there are :

(1) Default CDI producer starts up with org.activiti.cdi.impl.LocalProcessEngineLookup
   -> This is supposed to load the activiti.cfg.xml using Spring-context.
   -> You need to add /META-INF/beans.xml as usual for CDI.

(2) You may overload that default CDI producer writing your own (so that you get a chance to quit Spring some day).
    -> Provide a class that implements ProcessEngineLookup (see bitbucket resource).
    -> Define classname in /META-INF/services/org.activiti.cdi.spi.ProcessEngineLookup

Checking with the bitbucket sample code, (2) is OK, so what is wrong with (1) ?

The cause is contained within the first lines of the complete stacktrace : a NoClassDefFoundError (!)
Caused by: java.lang.NoClassDefFoundError: org/springframework/core/env/EnvironmentCapable


So actually, this is just a springframework version mismatch (!) The user guides still asks for adding spring-context3.0.3.RELEASE.
BUT currently, Activiti 5.12.1 defines spring 3.1.2...

With the correct version, activiti-CDI is stating as a charm !
These are the dependencies I used :

   

... Shall this post save your time ;)





4 commentaires:

  1. Thanks, this help me.
    Greetings from Brazil.

    RépondreSupprimer
  2. Thanks a lot!

    Greetings from Brazil too. :)

    RépondreSupprimer
    Réponses
    1. help me sandro pliz ,how integrer jsf with activiti_cdi

      Supprimer
  3. can you help me ,haw integrer jsf with activiti-cdi pliz pliz

    RépondreSupprimer