Docker - Unable to contact EngineAPI

Hello,

I’m trying to create multiple docker container with a docker-compose.
I have 3 containers:

  • bonita
  • postgres
  • webapps

In my webapp i have one application that’s use EngineAPI to do some actions, like launch a process.
When i’m tryin to connect to bonitaEngine, i’ve got this error:

java.lang.reflect.UndeclaredThrowableException
        at com.sun.proxy.$Proxy395.login(Unknown Source)
        at com.mycompany.rest.bonita.services.impl.BonitaAuthenticationServiceImpl.loginWithDefaultUser(BonitaAuthenticationServiceImpl.java:73)
		....
Caused by: org.apache.http.client.HttpResponseException:
        at org.bonitasoft.engine.api.HTTPServerAPI.invokeMethod(HTTPServerAPI.java:146)
        at org.bonitasoft.engine.api.impl.ClientInterceptor.invoke(ClientInterceptor.java:86)
        at com.sun.proxy.$Proxy395.login(Unknown Source)
		....	

That’s caused because i’ve got a **404 **response from the method:

public APISession loginWithDefaultUser() throws LoginException {
        logger.debug("-- Login a bonita...");
        Map<String, String> settings = new HashMap<String, String>();
        settings.put("server.url", serveurUrl);
        settings.put("application.name", appName);

        logger.debug("Connexion : "+serveurUrl+" - "+appName+" - "+user);
        APITypeManager.setAPITypeAndParams(ApiAccessType.HTTP, settings);
        // get the LoginAPI using the TenantAPIAccessor
        LoginAPI loginAPI;
        try {
            loginAPI = TenantAPIAccessor.getLoginAPI();
            // log in to the tenant to create a session
            **APISession apiSession = loginAPI.login(user, password);//<== This method**
            logger.debug("-- Login to bonita OK");
            return apiSession;
        } catch (BonitaHomeNotSetException | ServerAPIException | UnknownAPITypeException | LoginException ex) {
            logger.error("Unable to connect to bonita", ex);
            throw new LoginException(ex);
        }catch(Exception exception){
            logger.error("Unexpected error occurred", exception);
            throw new LoginException(exception);
        }
    }

My url is: http://cbonita:8080 (cbonita is my container’s name)
my user = tech_user
my psw = secret

Furthermore I have try to use curl to the RestAPI from my webbapp like that:

curl -c cookie.txt -s -o /dev/null -d 'username=tech_user&password=secret&redirect=false' -w ''%{http_code}'' http://cbonita:8080/bonita/loginservice

That curl works perfectly. So, i don’t know why my EngineAPI call doesn’t work.

Someone have an issue about that? ^^

Regards

Hello,

If you use the official image https://hub.docker.com/_/bonita
as described in the documentation in security section, the default behavior is to deactivate HTTP_API.
For specific needs you can override this behavior by setting HTTP_API to true :

docker run  -e HTTP_API=true  --name bonita -d -p 8080:8080 bonita

I will test that soon, thanks

Thanks a lot ! It’s working perfectly !