« Return to Thread: Instantiate process from application

Re: Re: Instantiate process from application

by Luke Rasmussen :: Rate this Message:

Reply to Author | View in Thread

We have been trying to get a program working to connect to Shark using code from the Shark documentation and this mailing list.

We are wondering if anyone can help troubleshoot or explain why we are geting the error:
javax.transaction.NotSupportedException: Nested transactions not supported2009-01-12 10:11:44,587: SharkConnectionImpl -> Unexpected error while user admin loggs on
java.lang.Exception: No transaction begun.
    at org.enhydra.shark.SharkTxSynchronizationFactory.createTxSynchronization(SharkTxSynchronizationFactory.java:83)
    at org.enhydra.shark.SharkUtilities.getTxSynchronization(SharkUtilities.java:469)
    at org.enhydra.shark.SharkUtilities.getResourceFromCache(SharkUtilities.java:492)
    at org.enhydra.shark.SharkUtilities.getResource(SharkUtilities.java:515)
    at org.enhydra.shark.SharkConnectionImpl.connect(SharkConnectionImpl.java:73)
    at org.enhydra.shark.client.utilities.SharkInterfaceWrapper.getSharkConnection(SharkInterfaceWrapper.java:329)
    at org.marshfieldclinic.Shark.MSharkClientConnector.main(MSharkClientConnector.java:91)


We are using the following code:
public static void main(String[] args)
        {
            try {
              System.out.println("1");
                 SharkInterfaceWrapper.setProperties("X:\\tws-community-2.2\\conf\\Shark.conf", true);
                 System.out.println("1a");
                 
                  UserTransaction ut = (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction");
           
                Map cntxt = new HashMap();
               
                ut.begin();
               
                String username = "admin";
                SharkConnection sc = SharkInterfaceWrapper.getSharkConnection(username, null);

                ut.commit();

                  System.out.println("7");
                  WMConnectInfo wmci=new WMConnectInfo("", "", "", "");

                  System.out.println("8");
                  sc.connect(wmci);
       
                ut.begin();
       
                String pkgId = "1";
                String pDefId = "0";
                String procDefName = SharkInterfaceWrapper.getShark()
                   .getXPDLBrowser()
                   .getUniqueProcessDefinitionName(sc.getSessionHandle(), pkgId, "", pDefId);
                WfProcessMgr mgr = sc.getProcessMgr(procDefName);
       
                ut.commit();
       
                WfProcess process = mgr.create_process(null);
       
                /*if you want to set process variables now, then you can do so now as
                follows:*/
                process.set_process_context(cntxt);
       
                process.start();
                ut.commit();
            }
            catch (Exception exc) {
                System.out.println("Exception: " + exc);
                System.out.println("Message: " + exc.getMessage());
                exc.printStackTrace();
            }
        }

Thank you,

Luke R.
Marshfield Clinic


On Fri, Dec 19, 2008 at 3:18 PM, Luke Rasmussen <lrasm274@...> wrote:
Thank you very much Geeta!  I'll give this a shot and let you know how it works for us.
 
Luke R.
Marshfield Clinic


 
On Wed, Dec 17, 2008 at 12:59 PM, <gramani@...> wrote:
Hi Luke,

Here's some code sample from our application, which may help you:

ut = SharkInterfaceWrapper.getUserTransaction();
ut.begin();

/*"xpdl" below is a domain object for us which has info about package
defintion, verison etc. and getProcessManager() is * a method I will
reproduce below.
*/
WfProcessMgr processMgr = getProcessManager(sharkConnection, xpdl);

process= processMgr.create_process(null);

/*if you want to set process variables now, then you can do so now as
follows:*/
process.set_process_context(myContextMap);

process.start();
ut.commit();

Here's the getProcessManager method using our xpdl domain object:
private WfProcessMgr getProcessManager(SharkConnection sharkConnection,
                 Xpdl xpdl) throws Exception {
     XPDLBrowser xpdlb = Shark.getInstance().getXPDLBrowser();
     String procDefName =
           xpdlb.getUniqueProcessDefinitionName(
                       sharkConnection.getSessionHandle(),
                       xpdl.getPackageId(),
                       (new Integer(xpdl.getVersion())).toString(),
                       xpdl.getProcessDefinitionId());
     WfProcessMgr mgr = sharkConnection.getProcessMgr(procDefName);
     return mgr;
}

Hope this helps,
regards,
Geeta




            "Luke Rasmussen"
            <lrasm274@...
            om>                                                        To
                                      shark@...
            12/17/2008 05:09                                           cc
            PM
                                                                  Subject
                                      [shark] Instantiate process from
            Please respond to         application
              shark@...









We are trying to use the Shark API to instantiate (and interact with) a
process from an external Java application.

We looked in the Shark code (latest from CVS) and found the SharkTest area,
however it appeared to have a lot of extra calls.  Our engine is running
and the process is loaded, so what is the minimum amount of code needed to
obtain a link to the server instance and instantiate it.  Is this already
documented somewhere?  Has anyone done this, and would you be willing to
post a simple example to the list?

Thanks in advance for your help.

Luke R.
Marshfield Clinic

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
--
You receive this message as a subscriber of the shark@... mailing list.
To unsubscribe: mailto:shark-unsubscribe@...
For general help: mailto:sympa@...?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws




--
You receive this message as a subscriber of the shark@... mailing list.
To unsubscribe: mailto:shark-unsubscribe@...
For general help: mailto:sympa@...?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws





--
You receive this message as a subscriber of the shark@... mailing list.
To unsubscribe: mailto:shark-unsubscribe@...
For general help: mailto:sympa@...?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

 « Return to Thread: Instantiate process from application