Version 1

    As described in this Jira: https://jira.jboss.org/jira/browse/SOA-1673, there is a classloading issue when trying to invoke an ESB Service from jBPM as part of a Seam application.  JBoss ESB provides out-of-the-box jBPM integration hooks (for example, EsbNotifier), however a conflict occurs when the Seam application (which most likely kicks off the jBPM process) includes its own copy of jbpm-jpdl.jar.  One workaround would be to remove this jar and deploy the process definition separately as a par archive via the jBPM console, however this is not doable if the Seam application requires jbpm-jpdl.jar for other purposes, for example: Seam pageflow.

     

    The JBoss ESB team is evaluating the best path forward to rectify this, however in the meantime there is a relatively straightforward workaround.  In short, classloader-scope the ear file (the seam application), and create your own custom jBPM ActionHandler that uses the ESB ServiceInvoker class to invoke the deployed ESB Service, rather than using one of the out-of-the-box ESB/jBPM ActionHandlers which depend on the jBPM library directly.

     

    Here are the steps, using the Seam dvdstore example as a starting point (please also see the attached jboss-seam-dvdstore.ear file):

     

    1. In the Seam dvdstore example, execute "ant archive", which creates jboss-seam-dvdstore.ear.  Leave jbpm-jpdl.jar in there!
    2. Create your own ActionHandler that calls ServiceInvoker.
    3. Scope the Seam ear classloading in jboss-seam-dvdstore.ear/META-INF/jboss-app.xml
      • <loader-repository>
            seam.jboss.org:loader=seam-dvd
            <loader-repository-config>
                java2ParentDelegation=false
            </loader-repository-config>
        </loader-repository>
        
    4. Edit the jBPM processdefinition to invoke the custom ActionHandler, which calls the ESB Service.  (You can refer to the attached See attached: jboss-seam-dvdstore.ear/ordermanagement1.jpdl.xml, or see below.)
      • <start-state name="start">
            <transition to="process">
                <action name="ShipItAction" class="org.jboss.soa.esb.services.jbpm.SOA_1673.EsbNotifier">
                    <esbCategoryName>FirstServiceESB</esbCategoryName>
                    <esbServiceName>SimpleListener</esbServiceName>
                    <bpmToEsbVars>
                        <mapping bpm="processInstance.id" esb="BODY_CONTENT"/>
                    </bpmToEsbVars>
                </action>
            </transition>
        </start-state>
        
    5. Make the custom ActionHandler class available to the classloader. To do this, I edited jboss-seam-dvdstore.ear/META-INF/application.xml and added this:
      • <module>
            <java>SOA-1673.jar</java>
        </module>
        
    6. Re-packag jboss-seam-dvdstore.ear, deploy and test:
      1. Deploy the ESB Service (for this example, you can use the Quickstart_helloworld.esb found in JBoss ESB or SOA-P's samples/quickstarts/helloworld via "ant deploy").
      2. Deploy the JDBC DataSource which the Seam ear application depends on (copy jboss-seam-dvdstore-ds.xml into JBoss' deploy directory).
      3. Deploy the Seam ear application (copy jboss-seam-dvdstore.ear into JBoss' deploy directory).
      4. Browse to http://localhost:8080/seam-dvdstore/
      5. Login as user1:password
      6. Click on Shop -> The Bourne Id -> Add To Cart -> Checkout -> Purchase -> Confirm
      7. See the ESB Service output in the server console:
        • 18:05:05,192 INFO [STDOUT]
          &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
          18:05:05,254 INFO  [STDOUT] Body: 1
          18:05:05,255 INFO [STDOUT]
          &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
          18:05:05,262 INFO  [STDOUT] Message structure: 
          18:05:05,262 INFO  [STDOUT] [1]
          

     

    Any questions, feel free to reach us in the JBoss ESB User Forum.