Sunday, July 22, 2012

Custom Java Connector in IBM BPM

IBM BPM (Lombardi), by default provides many java Integration connectors which can used to perform different operations like connecting to database, XSL transformation connector, LDAP connector, mail connector etc. But despite of all the available connectors we might need to perform certain operations which is not possible with IBM BPM like pulling data from some external system (Say, Filenet). In this kind of scenarios we can leverage the IBM BPM capability of custom java connectors or Webservice connectors.

In this post, lets see how to create simple Custom Java connector and pass an input to it and get a complex object as an output.


Pre-requisites for creating a java connectors.
In order to create the teamworks type object in custom java, retrieve the jar file "psclnt.jar" available at the location: C:\IBM\BPM\v7.5\BPM\Lombardi\lib\psclnt.jar. This jar file can be used to create teamworks object type in the custom java connector code.

Steps to create custom java connector using eclipse:
  • Create a java project in eclipse as shown in the figure below and create a reference to the jar file "psclnt.jar"  in the java project as shown below.


  • sample java connector class code 
              import teamworks.TWObject;
              import teamworks.TWObjectFactory;
              public class SimpleValueBean {
                      public TWObject simpleValueRet(String name) throws Exception{
 
                      TWObject twObject = TWObjectFactory.createObject("ValueBean");
                      twObject.setPropertyValue("name", name);
                      twObject.setPropertyValue("place", "Place");
                      return twObject;
                     }
             }

         ValueBean is the object of teamworks type which is defined in the lombardi.
  •  Now Create the jar for above code.
  • Attach the jar file as a server file in the IBM BPM as shown below. 

  • Now create an integration service and drag java integration on to design area. Now go to definition in properties tab and click on select, you can notice the sample.jar which contains the connector class that we have just created. Select that and you can notice the input and output mappings in the data mapping tab.

  • Create the neccessary input and output variable and map them to the connector's input and output variable.  Your custom java connector is ready to use.
  • Below shown is the variable structure of ValueBean as create in Lombardi.


 Hope this helps in creating custom java connector.



4 comments:

  1. when invoking the static method createObject, i always get

    Exception in thread "main" java.lang.NoClassDefFoundError: com.lombardisoftware.core.TeamWorksException
    at java.lang.J9VMInternals.verifyImpl(Native Method)
    at java.lang.J9VMInternals.verify(J9VMInternals.java:85)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:162)
    at dev.MyClass.main(MyClass.java:14)
    Caused by: java.lang.ClassNotFoundException: com.lombardisoftware.core.TeamWorksException
    at java.net.URLClassLoader.findClass(URLClassLoader.java:434)
    at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:665)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:644)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:358)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:627)
    ... 4 more


    any hints?

    ReplyDelete
  2. Have you imported pscInt.jar to your class path, while executing this ??

    ReplyDelete
  3. Hi, Im using ibm bpm 8.5, and Im having the same trouble.

    Which jar did I missed=

    ReplyDelete
  4. Hi, may i know how to pass the custom object (User Defined Type) as the argument to the java connector method in IBM BPM.

    ReplyDelete