Create instances of process from Java (step by step)

1
0
-1

Hi.

I need to create instances of one process deployed and runing on Jboss 5.1, from one Java app, so what are the steps for achieve this (please,if someone can explain me step by step I appreciate that) ?

(Using Bonita BPM 6.2.1 - Jboss 5.1)

Regards

1 answer

1
0
-1

Hi,

is this documentation not enough? http://documentation.bonitasoft.com/create-your-first-project-maven

Gabriel

Comments

Submitted by cdominguez.bravo on Wed, 02/19/2014 - 15:21

Hi Gabriel.

My scenario is diferent; My process is already deployed and running in Jboss 5.1, so I want to create instances from that process deployed via JAVA.

When I trying create the platform with the below code I get one exception:

Code:

  1. private static void createPlatform() throws BonitaException {<br />
  2. // login as platform administrator<br />
  3. <br />
  4. PlatformSession session = doPlatformLogin(PLATFORM_ADMIN, PLATFORM_PASSWORD);<br />
  5. <br />
  6. try {<br />
  7. System.out.println("Creating and initializing the platform ...");<br />
  8. // create and initialize the platform<br />
  9. getPlatformAPI(session).createAndInitializePlatform();<br />
  10. System.out.println("Platform created and initialized!");

  1. System.out.println("Starting node ...");<br />
  2. // start the node (make scheduler service to start)<br />
  3. getPlatformAPI(session).startNode();<br />
  4. System.out.println("Node started!");<br />
  5. } finally {<br />
  6. // logout<br />
  7. doPlatformLogout(session);<br />
  8. }<br />
  9. }

Exception:

  1. Exception in thread "main" org.bonitasoft.engine.exception.BonitaRuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'actorMappingService' defined in file [C:\BonitaBPMCommunity-6.2.1-JBoss-5.1.0.GA\bonita\server\platform\conf\services\cfg-bonita-actor-mapping-impl.xml]: Cannot resolve reference to bean 'persistenceService' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'persistenceService' defined in file [C:\BonitaBPMCommunity-6.2.1-JBoss-5.1.0.GA\bonita\server\platform\conf\services\cfg-bonita-persistence-hibernate.xml]: Cannot resolve reference to bean 'sequenceManager' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sequenceManager' defined in file [C:\BonitaBPMCommunity-6.2.1-JBoss-5.1.0.GA\bonita\server\platform\conf\services\cfg-bonita-sequence-impl.xml]: Cannot resolve reference to bean 'bonitaSequenceManagerDSJNDI' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bonitaSequenceManagerDSJNDI' defined in file [C:\BonitaBPMCommunity-6.2.1-JBoss-5.1.0.GA\bonita\server\platform\conf\services\cfg-bonita-ds.xml]: Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial<br />
  2. Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bonitaSequenceManagerDSJNDI' defined in file [C:\BonitaBPMCommunity-6.2.1-JBoss-5.1.0.GA\bonita\server\platform\conf\services\cfg-bonita-ds.xml]: Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial<br />
  3. Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in file [C:\BonitaBPMCommunity-6.2.1-JBoss-5.1.0.GA\bonita\server\platform\conf\services\cfg-bonita-transaction-api-impl.xml]: Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial<br />
  4. at org.bonitasoft.engine.api.impl.ServerAPIImpl.invokeMethod(ServerAPIImpl.java:122)<br />
  5. at org.bonitasoft.engine.api.impl.ClientInterceptor.invoke(ClientInterceptor.java:88)<br />
  6. at com.sun.proxy.$Proxy0.login(Unknown Source)<br />
  7. at org.bonita.example.BPMClient.doPlatformLogin(BPMClient.java:137)<br />
  8. at org.bonita.example.BPMClient.createPlatform(BPMClient.java:106)<br />
  9. at org.bonita.example.BPMClient.main(BPMClient.java:53)<br />
  10. Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'actorMappingService' defined in file [C:\BonitaBPMCommunity-6.2.1-JBoss-5.1.0.GA\bonita\server\platform\conf\services\cfg-bonita-actor-mapping-impl.xml]: Cannot resolve reference to bean 'persistenceService' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'persistenceService' defined in file [C:\BonitaBPMCommunity-6.2.1-JBoss-5.1.0.GA\bonita\server\platform\conf\services\cfg-bonita-persistence-hibernate.xml]: Cannot resolve reference to bean 'sequenceManager' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sequenceManager' defined in file [C:\BonitaBPMCommunity-6.2.1-JBoss-5.1.0.GA\bonita\server\platform\conf\services\cfg-bonita-sequence-impl.xml]: Cannot resolve reference to bean 'bonitaSequenceManagerDSJNDI' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bonitaSequenceManagerDSJNDI' defined in file [C:\BonitaBPMCommunity-6.2.1-JBoss-5.1.0.GA\bonita\server\platform\conf\services\cfg-bonita-ds.xml]: Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial<br />
  11. Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bonitaSequenceManagerDSJNDI' defined in file [C:\BonitaBPMCommunity-6.2.1-JBoss-5.1.0.GA\bonita\server\platform\conf\services\cfg-bonita-ds.xml]: Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial<br />
  12. Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in file [C:\BonitaBPMCommunity-6.2.1-JBoss-5.1.0.GA\bonita\server\platform\conf\services\cfg-bonita-transaction-api-impl.xml]: Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial<br />
  13. at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)<br />
  14. at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)<br />
  15. at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:630)<br />
  16. at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)<br />
  17. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)<br />
  18. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)<br />
  19. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)<br />
  20. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)<br />
  21. at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)<br />
  22. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)<br />
  23. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)<br />
  24. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)<br />
  25. at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:609)<br />
  26. at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)<br />
  27. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469)<br />
  28. at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)<br />
  29. at org.bonitasoft.engine.service.impl.AbsoluteFileSystemXmlApplicationContext.<init>(AbsoluteFileSystemXmlApplicationContext.java:41)<br />
  30. at org.bonitasoft.engine.service.impl.SpringPlatformFileSystemBeanAccessor.initializeContext(SpringPlatformFileSystemBeanAccessor.java:81)<br />
  31. at org.bonitasoft.engine.service.impl.SpringPlatformFileSystemBeanAccessor.getContext(SpringPlatformFileSystemBeanAccessor.java:72)<br />
  32. at org.bonitasoft.engine.service.impl.SpringPlatformFileSystemBeanAccessor.getService(SpringPlatformFileSystemBeanAccessor.java:67)<br />
  33. at org.bonitasoft.engine.service.impl.SpringPlatformServiceAccessor.getPlatformLoginService(SpringPlatformServiceAccessor.java:98)<br />
  34. at org.bonitasoft.engine.api.impl.PlatformLoginAPIImpl.login(PlatformLoginAPIImpl.java:52)<br />
  35. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br />
  36. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br />
  37. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br />
  38. at java.lang.reflect.Method.invoke(Method.java:597)<br />
  39. at org.bonitasoft.engine.api.impl.ServerAPIImpl.invokeAPI(ServerAPIImpl.java:292)<br />
  40. at org.bonitasoft.engine.api.impl.ServerAPIImpl.invokeAPI(ServerAPIImpl.java:217)<br />
  41. at org.bonitasoft.engine.api.impl.ServerAPIImpl.invokeMethod(ServerAPIImpl.java:105)<br />
  42. ... 5 more<br />
  43. Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'persistenceService' defined in file [C:\BonitaBPMCommunity-6.2.1-JBoss-5.1.0.GA\bonita\server\platform\conf\services\cfg-bonita-persistence-hibernate.xml]: Cannot resolve reference to bean 'sequenceManager' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sequenceManager' defined in file [C:\BonitaBPMCommunity-6.2.1-JBoss-5.1.0.GA\bonita\server\platform\conf\services\cfg-bonita-sequence-impl.xml]: Cannot resolve reference to bean 'bonitaSequenceManagerDSJNDI' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bonitaSequenceManagerDSJNDI' defined in file [C:\BonitaBPMCommunity-6.2.1-JBoss-5.1.0.GA\bonita\server\platform\conf\services\cfg-bonita-ds.xml]: Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial<br />
  44. at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)<br />
  45. at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)<br />
  46. at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:630)<br />
  47. at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)<br />
  48. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)<br />
  49. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)<br />
  50. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)<br />
  51. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)<br />
  52. at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)<br />
  53. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)<br />
  54. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)<br />
  55. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)<br />
  56. at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)<br />
  57. ... 33 more<br />
  58. Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sequenceManager' defined in file [C:\BonitaBPMCommunity-6.2.1-JBoss-5.1.0.GA\bonita\server\platform\conf\services\cfg-bonita-sequence-impl.xml]: Cannot resolve reference to bean 'bonitaSequenceManagerDSJNDI' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bonitaSequenceManagerDSJNDI' defined in file [C:\BonitaBPMCommunity-6.2.1-JBoss-5.1.0.GA\bonita\server\platform\conf\services\cfg-bonita-ds.xml]: Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial<br />
  59. at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)<br />
  60. at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)<br />
  61. at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:630)<br />
  62. at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)<br />
  63. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)<br />
  64. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)<br />
  65. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)<br />
  66. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)<br />
  67. at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)<br />
  68. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)<br />
  69. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)<br />
  70. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)<br />
  71. at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)<br />
  72. ... 45 more<br />
  73. Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bonitaSequenceManagerDSJNDI' defined in file [C:\BonitaBPMCommunity-6.2.1-JBoss-5.1.0.GA\bonita\server\platform\conf\services\cfg-bonita-ds.xml]: Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial<br />
  74. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)<br />
  75. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)<br />
  76. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)<br />
  77. at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)<br />
  78. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)<br />
  79. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)<br />
  80. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)<br />
  81. at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)<br />
  82. ... 57 more<br />
  83. Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial<br />
  84. at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)<br />
  85. at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)<br />
  86. at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)<br />
  87. at javax.naming.InitialContext.lookup(InitialContext.java:392)<br />
  88. at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)<br />
  89. at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)<br />
  90. at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)<br />
  91. at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)<br />
  92. at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)<br />
  93. at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)<br />
  94. at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201)<br />
  95. at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187)<br />
  96. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)<br />
  97. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)<br />
  98. ... 64 more

 

What could be wrong ? :-(

Submitted by celine.souchet on Wed, 02/19/2014 - 16:09

Hi,

If your process is already deployed, why do you create the platform ? It's already existed normally. An if your bundle is already started, the node too.

You need to login with your tenant in first, get the APISession :

final LoginAPI loginAPI = TenantAPIAccessor.getLoginAPI();
final APISession session = loginAPI.login(userName, password);

Then, get the ProcessAPI, and call the method to start a process instance :

final ProcessAPI processAPI = TenantAPIAccessor.getProcessAPI(session);

final ProcessInstance processInstance = processAPI.startProcess(yourProcessDefinition.getId());

Best regards,

CĂ©line

Notifications