Eric D. Schabell

Friday, February 5, 2010

jBPM v3.2.x Hibernate persistence bug - missing javax.jcr.Node

While trying to show hibernate persistence with jBPM v3.2.x I ran into a problem with a missing dependency. Details of the simple POJO class I was persisting, the hibernate mappings, error message encountered and solution tracing are provided below for those interested:

package com.sample.model;

// Sample person object for persistence checking.
public class Person {

 private Integer ssn;
 private String lastname;
 private String firstname;

 public void setFirstname(String firstname) {
  this.firstname = firstname;
 }
 public String getFirstname() {
  return firstname;
 }
 public void setLastname(String lastname) {
  this.lastname = lastname;
 }
 public String getLastname() {
  return lastname;
 }
 public void setSSN(Integer ssn) {
  this.ssn = ssn;
 }
 public Integer getSSN() {
  return ssn;
 }
}

The hibernate mappings were put into the person.hbm.xml file:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
 "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
 "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.sample.model" auto-import="false" default-access="field">
  <class name="Person">
   <id name="ssn" column="SSN"><generator class="native" /></id>
   <property name="lastname" column="LASTNAME" />
   <property name="firstname" column="FIRSTNAME" />
  </class>
</hibernate-mapping>

// First the errors I was getting in my logging (just the last bits):
...
DEBUG GraphElement - event 'process-start' on ProcessDefinition(main_flow)
 for Token(/)
DEBUG VariableContainer - create variable 'person' in 'TokenVariableMap[/]' 
with value 'com.sample.model.Person@1dfc547'
DEBUG Converters - adding converter 'D', 'org.jbpm.context.exe.converter.DoubleToStringConverter'
DEBUG Converters - adding converter 'C', 'org.jbpm.context.exe.converter.CharacterToStringConverter'
DEBUG Converters - adding converter 'B', 'org.jbpm.context.exe.converter.BooleanToStringConverter'
DEBUG Converters - adding converter 'Y', 'org.jbpm.context.exe.converter.BytesToByteArrayConverter'
DEBUG Converters - adding converter 'A', 'org.jbpm.context.exe.converter.DateToLongConverter'
DEBUG Converters - adding converter 'R', 'org.jbpm.context.exe.converter.SerializableToByteArrayConverter'
DEBUG Converters - adding converter 'I', 'org.jbpm.context.exe.converter.IntegerToLongConverter'
DEBUG Converters - adding converter 'H', 'org.jbpm.context.exe.converter.ShortToLongConverter'
DEBUG Converters - adding converter 'G', 'org.jbpm.context.exe.converter.FloatToDoubleConverter'
DEBUG Converters - adding converter 'F', 'org.jbpm.context.exe.converter.FloatToStringConverter'
DEBUG Converters - adding converter 'E', 'org.jbpm.context.exe.converter.ByteToLongConverter'
DEBUG HibernateLongIdMatcher - no current context so valueClass 
cannot be stored as a long-id-ref to a hibernate object
DEBUG HibernateStringIdMatcher - no current context so valueClass 
cannot be stored as a string-id-ref to a hibernate object

The path to the missing interface we traced from jbpm-jpdl.jar -> org.jbpm.context.exe -> jbpm.varmapping.xml file contains the following mapping:

<!-- JSR 170 JCR Node -->
    <jbpm-type>
      <matcher>
        <bean class="org.jbpm.context.exe.matcher.JcrNodeMatcher" />
      </matcher>
      <variable-instance class="org.jbpm.context.exe.variableinstance.JcrNodeInstance" />
    </jbpm-type>    

This leads to org.jbpm.context.exe.matcher.JcrNodeMatcher.class which imports the class not included in jBPM:

/*
 * Snipped the license code.
 */
package org.jbpm.context.exe.matcher;

import javax.jcr.Node;        <<<<<<<<<<<<<< MISSING!!!!

import org.jbpm.context.exe.JbpmTypeMatcher;

public class JcrNodeMatcher implements JbpmTypeMatcher {

  private static final long serialVersionUID = 1L;

  public boolean matches(Object value) {
    return (Node.class.isAssignableFrom(value.getClass()));
  }

}

My solution: added external jar to projects classpath, jcr-1.0.jar which provides the needed interface interface. Hope this saves you some time!

Thursday, February 4, 2010

Upgrade Fedora 11 to Fedora 12 howto

A few simple steps to upgrade:

# As root you would like to have a clean start to the
# upgrade, so get an update out of the way.
#
$ yum update rpm

$ yum -y update

$ yum clean all

# Should a new kernel install/update require it,
# reboot before continuing with the rest.
#
# Then install the preupgrade package.
#
$ yum install preupgrade

# For console upgrade, use:
#
$ preupgrade-cli "Fedora 12 (Constantine)"

# If you like gui's to upgrade, use this.
#
$ preupgrade

This is exactly the same process as I previously described with Fedora 10 to Fedora 11 upgrade.

Tuesday, February 2, 2010

Update Fedora 12 to Firefox 3.6 howto

I got tired of waiting for the main Fedora 12 repositories to provide Firefox 3.6. I dug around a bit and the following will get you a Firefox 3.6 version installed on your Fedora 12, so what are you waiting for?







$ sudo yum --enablerepo=rawhide update firefox

Friday, January 29, 2010

SNS Bank award lunch: 2009 Silver award for BPM & Workflow excellence

After much planning we were finally able to celebrate the SNS Bank 2009 Silver award for Global Excellence in BPM & Workflow. We got together with the entire team; the two authors, the project manager, the head of Java development and one of the original developers.

It was a nice three course lunch filled with stories about all the work that went into getting this chapter published and what led up to the award.

I presented the winners trophy to the SNS Bank and we look forward to following their BPM innovations into the future.

As you can see, the winners cup was used for the traditional winners champagne drinking ceremony.

Finally, we took a group photo to commemorate the event. I think this story is finally finished, but who knows? ;-)

Jazoon 2010 session submission

Just submitted a session to Jazoon 2010 that takes place on 1-3 June, 2010 in Zurich, Switzerland. I am curious as to what traction is in the market for this information.

Future proofing SOA projects with JBoss jBPM migration strategies
If you have applied all the best intentions in your jBPM projects you might now be searching for best practices. Based on experiences from the trenches, we offer insights into jBPM best practices that are meant to ensure future migration flexibility.

This session takes you on a tour of the following four tactical migration areas in a jBPM project:

    * process initialization layer
    * process definition & design layer
    * process implementations layer
    * SOA interaction layer

As we peel back these layers we will detail best practices and design tactics that will greatly simplify your jBPM future. A running case will be use based on a JBoss EAP / jBPM award winning implementation at SNS Bank from the Netherlands.

Thursday, January 28, 2010

Computable.nl Open Source - comments published on "Open Source: teveel vrijheid is ook niet goed"

Computable has published an opinion article written by a friend of mine entitled: Open source: teveel vrijheid is ook niet goed.

My comment was published along with the article, see the third cited expert under the article.

Wednesday, January 20, 2010

JBoss World 2010 jBPM session submission

I have submitted a session to JBoss World 2010 that will be in Boston, MA from June 22 - 25. The speakers list will be announced on 1 March 2010, so fingers crossed for the following abstract:

Sun Tzu and the art of jBPM migrations
Sun Tzu once wrote, "Strategy without tactics is the slowest route to victory.” If you have applied all the best intentions in your jBPM projects you might now be searching for best practices. Based on experiences from the trenches, we offer insights into jBPM best practices that are meant to ensure future migration flexibility.

This session takes you on a tour of the following four tactical migration areas in a jBPM project:
  • process initialization layer
  • process definition & design layer
  • process implementations layer
  • SOA interaction layer
As we peel back these layers we will detail best practices and design tactics that will greatly simplify your jBPM future. A running case will be use based on a JBoss EAP / jBPM award winning implementation at SNS Bank from the Netherlands.

Thursday, January 14, 2010

jBPM Developer Guide review - chapters 7 - 12 (part III of III)

Click on book to buy!
Back to jBPM Developer Guide review part II
Back to jBPM Developer Guide review part I

My final part of this book review will cover the last six chapters and provide a final conclusion.

Chapter 6
This chapter is an in depth look at how jBPM deals with persistence.

A must read chapter.

Chapter 7
Tasks are dealt with in the chapter with a very good example to show you how it all works. At this point that the book gives us a practical example instead of homework, bit of inconsistency here.

Still, a must read chapter.

Chapter 8
More persistence, dealing with how it happens when you hit wait states. Would have like to see more about how this is a best practice as too many jBPM implementations take the initial lead from the provided examples found on-line and implement everything in Nodes. Nothing mentioned about lazy initialization or loading in Hibernate, something you will run into in advanced cases when you implement your complicated processes.
A nice end to this chapter is provided by updating the running example process to use the techniques discussed in this chapter. This is nice.

A good chapter you need to read.

Chapter 9
More than you really need to know about process variables, but that is exactly what I want from a developers guide type of book. This chapter is a perfect example of what I want from every chapter in this type of book, well done! Strange finish though, the homework section is back in this chapter.

Don't miss this chapter, good developer guide material that will help make you the jBPM guru in your development shop.

Chapter 10
Here the author deals with advanced topics from jPDL, which means forks, joins, super states, process states, email nodes and property passing in your handlers. It is thorough, but I would really have expected some more suggestions as to best practices, especially on forks and joins, which WILL bite you in the butt on your real life implementations. It is a good chapter, finishing off jPDL for you.

Don't want to skip this chapter or you will have a half empty toolbox at work.

Chapter 11
When I read the title I was expecting advanced topics from real life practices to tell me about the best practices using the previous material. It turns out to be about applying the chapter 10 material to the running example, thus the author takes us through adding in super states and process states to his example process.

A very good handling of the asynchronous usage of jBPM and how the jobExecutor works finishes out this chapter. Very important stuff and I thought it was forgotten. It would have been more symmetric to first introduce this in the previous chapter and then apply it as was done with the other advanced topics, but this is a matter of style.

A good chapter to read and pay attention to the jobExecutor section.

Chapter 12
With a title of 'Going enterprise,' I was curious how we were going to finish out the book as this was the last chapter. Well, it is a good overview of the deeper configuration issues encountered when working in JEE environments.
There were lots of solution tips sprinkled in this chapter, nice touch. The jobExecutor is handled but this time interacting with JMS queues. Timers, reminders and the Mail service are covered.

Then we hit a wall. The book it seems is now finished. No conclusion, no tying it all together with the final look at our running example project and no summary of the entire book. This feels like I am missing chapters or left hanging. Bummer.

This chapter is very important none the less, don't think of skipping this one.

Final conclusion

So my final conclusions are that this book is very much an improvement on the previous jBPM PACKT publishing offerings. It does cover jBPM fairly well and for a beginner it is now the place to start your education (should you decide not to take the Red Hat education offerings). Go out and get your copy, it will help you along the road to becoming a guru in your jBPM development projects.

What about my running list of questions and impressions? Here they are for posterity, maybe they will make it into future publications:
  • extremely disappointed with the readability/editing job done by PACKT publishing as mentioned in part I (again, this has nothing to do with the author)

  • no resources or references section in the book
  • lots of Wikipedia references in-line, never a good thing to use as a primary reference
  • miss exception handling as an advanced feature?
  • in handling of a Nodes and Transitions nothing is mentioned about dynamic transitions
  • no best practices given when implementing jBPM projects?
  • the author gives us "homework" in the first three chapters, but then it just stops until the ninth chapter, rather a shame