Error trying to get TransportRequestDAO - java.lang.ClassNotFoundException: com.company.model.TransportRequestDAOImpl
Hello. I am trying to retrieve data from business variable in java application. I found this thread https://community.bonitasoft.com/questions-and-answers/access-business-d... 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/client-bdm.zip. 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(TomcatEmbeddedWebappClassLoader.java:52) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119) ~[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!
Yes it's not straightforward to access BDM object from an external Java application.
Here is a procedure:
- 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:
File file = new File("/Users/lionel/Bonita/sandbox/bdmClient.zip");
- 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:
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