Error trying to get TransportRequestDAO - java.lang.ClassNotFoundException:


Hello. I am trying to retrieve data from business variable in java application. I found this thread and main advice was to add bdm-model.jar and bdm-dao.jar in my pom.xml. But problem is - there is no such files in BONITA_HOME/engine-server/work/tenants/1/data-management-client/ There is no such path, no directories. (I am using bonita v7.5).

So, i have found the other solution - add bdm-client-pojo.jar to dependencies. So, i did that and i am trying to call something like that:
BusinessObjectDAOFactory daoFactory = new BusinessObjectDAOFactory();
TransportRequestDAO transportRequestDAO = daoFactory.createDAO(apiSession, TransportRequestDAO.class);

and i am getting this error:
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedWebappClassLoader.loadClass( ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass( ~[tomcat-embed-core-8.5.20.jar:8.5.20]
at java.lang.Class.forName0(Native Method) ~[na:1.8.0_121]


There is no TransportRequestDAOImpl class in my bdm-client-pojo.jar and i have no idea what should i do to fix this problem. Please help!

1 answer

This one is the BEST answer!


Yes it's not straightforward to access BDM object from an external Java application.

Here is a procedure:

  1. Get BDM jars.

To get the Jars required by your application, you need to extract it from the DB. The API provides a method for that: tenantAdministrationAPI.getClientBDMZip()

So you can execute the following to write it on your filesystem:

      TenantAdministrationAPI tenantAdministrationAPI = org.bonitasoft.engine.api.TenantAPIAccessor.getTenantAdministrationAPI(session);
            File file = new File("/Users/lionel/Bonita/sandbox/");
            FileUtils.writeByteArrayToFile(file,  tenantAdministrationAPI.getClientBDMZip());
  1. Add dependencies.

The code to extract the Jars actually produce a ZIP file. You need to expand it and add the following libraries to your project build path: bdm-dao.jar and bdm-model.jar

Then your project will also need the jar bonita-common-7.5.4.jar (for the version 7.5.4). You can either find it in the Studio workspace or add it as a Maven dependency:

<dependency> <groupId>org.bonitasoft.engine</groupId> <artifactId>bonita-common</artifactId> <version>7.5.4</version> </dependency>



Submitted by amanemys_1352033 on Fri, 09/29/2017 - 10:41

Thank you! I wonder why there is no information about this in bonita documentation (in my opinion this is common use case, so this information should be added to examples of engine api section). In any case, thanks again