I finally got JBPM 3.1.1 working on JBoss 4.0.4. It did take some doing and browsing the forum. There were however a few steps missing.
Inorder to run JBPM 3.1.1 on top of JBoss 4.0.4 you need to follow the following steps.
1. The JBoss 4.0.4 uses hibernate 3.2 CR 2. This has ehcache-1.2 by default in it. However, JBPM and the default jbpm webapp is compiled using hibernate 3.1 and ehcache-1.1.
2. To get everything going I had to build everything under jbpm directory using the hibernate 3.1 and ehcache-1.2 library. Another appealing solution is to use hibernate 3.2 CR2, but the jbpm webapp won't compile with it.
3. On Jboss 4.0.4 under default/lib change the hibernate 3.2 CR2 with the hibernate from jbpm-starters-kit/jbpm/lib/hibernate and put in ehcache-1.2.
4. Lastly use the above 2 libs for all your process compilations.