Bonita API Connection in LOCAL mode
Hi,
Since Bonita 7.4 we have a avertissement while connecting to bonita in HTTP mode :
AVERTISSEMENT: You are declaring an API access to Bonita BPM Engine as a remote connection, whereas it looks like you are running in the same JVM. You should use LOCAL connection, using constant 'ApiAccessType.LOCAL'
My code to connect is
System.setProperty(BonitaHome.BONITA_HOME, parametres.getBonitaHome());
Map<String, String> map = new HashMap<String, String>();
map.put("server.url", parametres.getBonitaUrlServeur());
map.put("application.name", parametres.getBonitaNomApplication());
APITypeManager.setAPITypeAndParams(ApiAccessType.HTTP, map);
final String username = parametres.getBonitaLogin();
final String password = parametres.getBonitaPassword();
LoginAPI mLoginAPI = TenantAPIAccessor.getLoginAPI();
session = mLoginAPI.login(username, password);
processAPI = TenantAPIAccessor.getProcessAPI(session);
But changing ApiAccessType.HTTP to LOCAL failed the connection :
org.bonitasoft.engine.exception.ServerAPIException: java.lang.reflect.InvocationTargetException
java.lang.IllegalStateException: 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
Thanks for ideas.
I was with the same "problem". Found that the project had an unneeded (hope so) dependency with bonita-server in pom. I did took it out and no warnings anymore. Still with ApiAccessType.HTTP.
I see.
According to the source code, the engine try to load the class ProcessAPIImpl to check whether the engine is accessible in LOCAL mode.
The check can be misleaded if you load the jar bonita-server in the classpath of your Java program. Could you check whether or not you have this Jar file present in your classpath. If so, try to remove it and see if the message went away.
Cheers
Comments
Hi Lionel,
I don't think the problem is a jar one because the connexion is going very well in HTTP mode... As the AVERTISSMENT message says :
You are declaring an API access to Bonita BPM Engine as a remote connection, whereas it looks like you are running in the same JVM. You should use LOCAL connection, using constant 'ApiAccessType.LOCAL
. So my question was how to access api in local mode since I have a problem just changing the ApiAccessType value...
Thanks
OK.
I begin understanding, the API Access is not an conversation mode with API but an access mode to the API definition... And whereas the bonita jar are in the library path of my application, I can't use the ApiAccessType.LOCAL.
Is this really what I understand ?
Comments
Where do you run this code? In a separate application?
Yes.
In a main program java witch go on in a service and make some treatments for process instances.