Bonita API Connection in LOCAL mode

1
0
-1

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.

Comments

Submitted by Lionel Palacin on Thu, 02/09/2017 - 19:43

Where do you run this code? In a separate application?

Submitted by 3Fred9 on Fri, 02/10/2017 - 09:04

Yes.

In a main program java witch go on in a service and make some treatments for process instances.

2 answers

1
0
-1

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

Submitted by 3Fred9 on Mon, 02/13/2017 - 08:50

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

Submitted by Lionel Palacin on Mon, 02/13/2017 - 15:27

Hi,

What I was trying to say is that in your case, the connexion between your application and the Bonita Engine will work only on HTTP mode. The Local Mode won't work, as the class from the bonita engine and your application are in different class paths.

The message here is misleading. But it is displayed due to the fact that you load the bonita-server.jar in your class path.

Cheers

Submitted by 3Fred9 on Mon, 02/13/2017 - 15:48

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 ?

1
-1
-1
Notifications