[Resolved] Standalone JAVA client to connect to the Bonita execution engine

Chandan.Mishra2's picture
Submitted by Chandan.Mishra2 Tue, 03/27/2012 - 13:21

I have a java class intending to conenct to the process engine via api-type "EJB3".

I have checked through the conf.bat file and have verified the properties of



a. initial context factory,

b. provider url

c. api-type



The Jaas config file contains the following entry-

BonitaAuth {

org.ow2.bonita.identity.auth.BonitaIdentityLoginModule required;

};



BonitaStore {

org.ow2.bonita.identity.auth.BonitaRemoteLoginModule required;

org.jboss.security.ClientLoginModule required password-stacking=useFirstPass;

};





The exception I get here is -



Mar 27, 2012 4:44:07 PM org.ow2.bonita.util.AccessorUtil resetContext

INFO: API-Type: EJB3 has been specified through property: org.ow2.bonita.api-type

org.ow2.bonita.facade.exception.BonitaInternalException: Bonita Error: baa_CAPII_1

Ouch! Unexpected error: java.lang.NoSuchMethodException: javax.naming.Reference.getProcess(org.ow2.bonita.facade.uuid.ProcessDefinitionUUID, java.util.Map)



at org.ow2.bonita.facade.interceptor.ClientRemoteAPIInterceptor.invoke(ClientRemoteAPIInterceptor.java:152)

at $Proxy2.getProcess(Unknown Source)

at com.self.bonita.validator.service.BonitaClientApp.main(BonitaClientApp.java:69)

Caused by: java.lang.NoSuchMethodException: javax.naming.Reference.getProcess(org.ow2.bonita.facade.uuid.ProcessDefinitionUUID, java.util.Map)

at java.lang.Class.getMethod(Unknown Source)

at org.ow2.bonita.facade.interceptor.ClientRemoteAPIInterceptor.invoke(ClientRemoteAPIInterceptor.java:135)

... 2 more



The java code for the client is -



private static final String LOGIN = "admin";

private static final String PSSWD = "bpm";

private static final String jaasFile = "jaas-jboss.cfg";



public static void main(String[] args) throws Exception {



//set system properties

System.setProperty(BonitaConstants.API_TYPE_PROPERTY, "EJB3");

/System.setProperty(BonitaConstants.INITIAL_CONTEXT_FACTORY_PROPERTY, "org.jnp.interfaces.NamingContextFactory");

System.setProperty(BonitaConstants.PROVIDER_URL_PROPERTY, "jnp://127.0.0.1:1099");
/

System.setProperty(BonitaConstants.JAAS_PROPERTY, jaasFile);



System.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");

System.setProperty("java.naming.provider.url", "jnp://localhost:1099");



//login

//verify the user exists

LoginContext loginContext = new LoginContext("BonitaStore",

new SimpleCallbackHandler(LOGIN, PSSWD));

loginContext.login();



//get he APIs

//final ManagementAPI managementAPI = AccessorUtil.getManagementAPI();

final RuntimeAPI runtimeAPI = AccessorUtil.getAPIAccessor().getRuntimeAPI();

final QueryRuntimeAPI queryRuntimeAPI = AccessorUtil.getAPIAccessor().getQueryRuntimeAPI();

final QueryDefinitionAPI queryDefinitionAPI = AccessorUtil.getAPIAccessor().getQueryDefinitionAPI();



try {



ProcessDefinitionUUID processUUID = new ProcessDefinitionUUID("ExternalWebAppIntegratn", "1.0");

ProcessDefinition process = queryDefinitionAPI.getProcess(processUUID);

System.out.println("BonitaClientApp.main() [" + process + "]");

//instantiate process

ProcessInstanceUUID instanceUUID = runtimeAPI.instantiateProcess(processUUID);

System.out.println("----------------\nNew process instance Created\n----------------");



final Collection taskList = queryRuntimeAPI.getLightTaskList(instanceUUID, ActivityState.READY);

if (taskList.size() != 1) {

throw new Exception("Incorrect list size. Actual size: " + taskList.size());

}



//execute task

final LightTaskInstance taskInstance = taskList.iterator().next();

runtimeAPI.executeTask(taskInstance.getUUID(), true);

System.out.println("----------------\nTask executed\n----------------");



final InstanceState state = queryRuntimeAPI.getProcessInstance(instanceUUID).getInstanceState();

/if(!state.equals(InstanceState.FINISHED)){

throw new Exception("Incorrect state. Actual state: " + state);

}
/



System.out.println("----------------\nApplication executed sucessfully\n----------------");



} catch (Exception e) {

e.printStackTrace();

} finally {

loginContext.logout();

}



}



Kindly let me knwo what I am doing wrong here.



Regards

Chandan.

  • like

Comments

Hi, I don´t use System.setProperty(...), directly I use a jndi.properties file in the classpath with:


jboss JNDI properties

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory

java.naming.provider.url=jnp://localhost:1099

java.naming.factory.url.pkgs=org.jnp.interfaces



and it works fine!!!

  • like

Hi thanks for the reply.

Adding the jndi.properties in the classpath didnt solve my problem.

I changed the jaas.cfg file as well to



Bonita {

org.ow2.bonita.identity.auth.BonitaRemoteLoginModule required logins="john,jack,james, admin, UnauthorizedLoginForTest" passwords="bpm, bpm, bpm, bpm, UnauthorizedPasswordForTest";

};





The exception I get is, (which I must say dont indicate much)



org.ow2.bonita.facade.exception.BonitaInternalException: Bonita Error: baa_CAPII_1

Ouch! Unexpected error: java.lang.NoSuchMethodException: javax.naming.Reference.deploy(org.ow2.bonita.facade.def.element.BusinessArchive, java.util.Map)



at org.ow2.bonita.facade.interceptor.ClientRemoteAPIInterceptor.invoke(ClientRemoteAPIInterceptor.java:152)

at $Proxy0.deploy(Unknown Source)

at com.self.bonita.validator.service.BonitaClientApp.main(BonitaClientApp.java:79)

Caused by: java.lang.NoSuchMethodException: javax.naming.Reference.deploy(org.ow2.bonita.facade.def.element.BusinessArchive, java.util.Map)

at java.lang.Class.getMethod(Unknown Source)

at org.ow2.bonita.facade.interceptor.ClientRemoteAPIInterceptor.invoke(ClientRemoteAPIInterceptor.java:135)



Can you please share your classpath, jass-config content with me?

  • like

Has anyone solve this problem?

I am getting the same error and i followed the tutorials and the documentation.

I deployed bonita engine and processes in JBoss 5.1.

I deployed my client application in JBoss 4.2.

From my client i am trying to instantiate the process, but getting NoSuchMethodException



Regards

Rakesh

  • like