AnsweredAssumed Answered

Migrating example source code from the Manning book

Question asked by jemmerling on Jun 4, 2015
Latest reply on Jun 13, 2015 by jemmerling
If anyone is interested, I migrated the source code examples from the Manning book to the latest version of Activiti (5.17.0).

First thing to be aware of is the installation process described in the book has been phased out, see http://bpmn20inaction.blogspot.nl/2013/02/activiti-in-action-updates-part-1.html.

This is for the bpmn-examples project only (for now).

Then some modification to the POM. Activiti and Spring must both be upgraded:

      <activiti-version>5.17.0</activiti-version>
      <spring-version>4.0.6.RELEASE</spring-version>

Also this <pluginManagement/> tag must be added. I don't know enough about Maven to know why:
  <build>
     <pluginManagement>
    <plugins>

I commented out everything other than the class declaration for the ProcessInitiator example for Chapter 9, as the Spring Annotations have been discontinued and this example would seem to longer serve any useful purpose.

In the LDAP example (Chapter 10) there were some API changes. GroupManager becomes GroupEntityManager.

   @Override
   public List<Group> findGroupByQueryCriteria(GroupQueryImpl query, Page page)/* {
      // TODO Auto-generated method stub
      return super.findGroupByQueryCriteria(query, page);
   }

   @Override
  public List<Group> findGroupByQueryCriteria(Object query, Page page)*/ {

This method went away (not that it was exactly doing anything to begin with:

   /*@Override

  public GroupEntity findGroupById(String groupId) {
      throw new ActivitiException("LDAP group manager doesn't support finding a group by id");
  }*/

To populate the Activiti schema in H2 I used the DbSchemaCreate program. I suppose the old ANT script took care of this.

The default URL for separately installed H2 is
jdbc:h2:~/test
. The book example expects
jdbc:h2:tcp://localhost/~/activiti
. I suppose the ANT script took care of that. So there is an activiti.cfg.xml in which you can change the URL but that is for Spring to use, and the BookOrderTest class doesn't seem to use Spring for this. Instead, the URL is hardcoded (I found where but don't remember now). So the get the test to use the correct URL I added a line to change the URL after the fact:

      ProcessEngineConfiguration config = ProcessEngineConfiguration
            .createStandaloneProcessEngineConfiguration();
      config.setJdbcUrl("jdbc:h2:~/test");
      ProcessEngine processEngine = /*ProcessEngineConfiguration
         .createStandaloneProcessEngineConfiguration()*/
      config
          .buildProcessEngine();

After that I was able to get the BookOrderTest to work.

If anybody wants me to upload my modified workspace (actually just the bpmn-examples project) I would be happy to oblige. All advice is welcome.

Thanks to Tijs and Joram for the help they gave me!

–John Emmerling

Outcomes