Bonita API Connection in LOCAL mode
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
Map<String, String> map = new HashMap<String, String>();
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.
Where do you run this code? In a separate application?
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.
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...
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 ?