# Access a business data object using the Java API (V 7.1.4)

**URL:** <https://community.ofelia.com/t/access-a-business-data-object-using-the-java-api-v-7-1-4/6793>\
**Category:** Q&A\
**Created:** [24 December 2015 16:37 UTC](https://community.ofelia.com/t/access-a-business-data-object-using-the-java-api-v-7-1-4/6793 "2015-12-24T16:37:05Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![ephemeris.lappis](https://avatars.discourse-cdn.com/v4/letter/e/76d3ee/32.png) [@ephemeris.lappis](https://community.ofelia.com/u/ephemeris.lappis)\
**Post date:** [24 December 2015 16:37 UTC](https://community.ofelia.com/t/access-a-business-data-object-using-the-java-api-v-7-1-4/6793/1 "2015-12-24T16:37:05Z")

</div>

Hello.

I’ve not found any operation in the Java Engine API to retrieve a business data object associated with a process instance, given its id for example.

The BusinessDataAPI.getProcessBusinessDataReference() doesn’t seem to be the good way.

And I’ve not seen any solution from the ProcessAPI…

Anyone can help me ?

Thanks a lot.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/community_bonitasoft/original/2X/6/6b7b18c0478f2645369e82e009b65e3b97f2cc12.svg) [@system](https://community.ofelia.com/u/system)\
**Post date:** [29 December 2015 11:12 UTC](https://community.ofelia.com/t/access-a-business-data-object-using-the-java-api-v-7-1-4/6793/2 "2015-12-29T11:12:24Z")

</div>

**Edit** : my initial answer was incorrect, here is a solution to access a business data object using Bonita BPM Java client library configured to access Bonita BPM Engine over HTTP.

This Java code use BusinessDataAPI and DAO classes to access Business Data variables content:

// bonita-client library configuration to connect to Bonita BPM Engine  
Map\<String, String\> map = new HashMap\<\>();  
map.put(“server.url”, “[http://localhost:8080/](http://localhost:8080/)”);  
map.put(“application.name”, “bonita”);  
APITypeManager.setAPITypeAndParams(ApiAccessType.HTTP, map);

// Login  
LoginAPI loginAPI = TenantAPIAccessor.getLoginAPI();  
APISession session = loginAPI.login(“walter.bates”, “bpm”);

// Get a reference to BusinessDataAPI  
BusinessDataAPI businessDataAPI = TenantAPIAccessor.getBusinessDataAPI(session);

// Use BusinessDataAPI to retrieve the process instance business variable  
// We need to cast it to the appropriate class (SimpleBusinessDataReference or MultipleBusinessDataReference)  
SimpleBusinessDataReference businessDataReference = (SimpleBusinessDataReference)businessDataAPI.getProcessBusinessDataReference(“vacationAvailable”, 2);

// Get storage id (i.e. persistence id) of the business variable  
Long storageId = businessDataReference.getStorageId();

// Create DAO for the business data  
BusinessObjectDAOFactory daoFactory = new BusinessObjectDAOFactory();  
VacationAvailableDAO vacationAvailableDAO = daoFactory.createDAO(session, VacationAvailableDAO.class);

// Use DAO to find the business variable using the storage id (i.e. persistence id)  
VacationAvailable vacationAvailable = vacationAvailableDAO.findByPersistenceId(storageId);

In your project dependencies you need:

org.bonitasoft.bdm bdm-dao 0.0.2-SNAPSHOT system /path/to/bdm-dao.jar org.bonitasoft.bdm bdm-model 0.0.2-SNAPSHOT system /path/to/bdm-model.jar org.javassist javassist 3.18.1-GA org.bonitasoft.engine bonita-client 7.1.4

You can get bdm-dao.jar and bdm-model.jar in BONITA\_HOME/engine-server/work/tenants/1/data-management-client/client-bdm.zip file.

The DAO classes benefit from Bonita Java client library to access to remote engine.

---

<div class="post-metadata">

**Author:** ![ephemeris.lappis](https://avatars.discourse-cdn.com/v4/letter/e/76d3ee/32.png) [@ephemeris.lappis](https://community.ofelia.com/u/ephemeris.lappis)\
**Post date:** [11 January 2016 11:47 UTC](https://community.ofelia.com/t/access-a-business-data-object-using-the-java-api-v-7-1-4/6793/3 "2016-01-11T11:47:41Z")

</div>

Hello Antoine.

First, thanks for your new answer.

I’ve already seen the kind of integration example you explain. I’ve already had a look at the location and content of the DAO JARs in my studio folders.

It seems a bit difficult to go on this way, mainly because of the integration process that makes java code of our ESB modules depending on generated JARs that may change often during the cycles of an agile project. More, the DAO dependencies are not easy to manage when several persons both work on Bonita processes design and ESB services code.

I think I will try the solution you describe to evaluate it, but te REST API, despite my first idea, seems to be the preferred way to access business objects. It doesn’t constrain services development with instable DAO code. Although it needs a bit of wrapping code (for example using Spring RestTemplate), it also avoids the packaging of the Bonita Java dependencies.

I go on testing both solutions, and come back to give you feedback about my results.

Any advice from you is welcome !

Thanks again.

Regards.

---

<div class="post-metadata">

**Author:** ![amitroyes3](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@amitroyes3](https://community.ofelia.com/u/amitroyes3)\
**Post date:** [25 January 2016 09:24 UTC](https://community.ofelia.com/t/access-a-business-data-object-using-the-java-api-v-7-1-4/6793/4 "2016-01-25T09:24:01Z")

</div>

thanks for your reply but i have added those two jar to project by buildpath and maven try with both the ways still it gives exception when i deploy it to portal and call that api

---

<div class="post-metadata">

**Author:** ![emmanuel.duchastenie](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/emmanuel.duchastenie/32/723_2.png) [@emmanuel.duchastenie](https://community.ofelia.com/u/emmanuel.duchastenie)\
**Post date:** [6 May 2020 21:47 UTC](https://community.ofelia.com/t/access-a-business-data-object-using-the-java-api-v-7-1-4/6793/5 "2020-05-06T21:47:14Z")

</div>

Hi Pedro,

In Bonita versions 7.8+... there are several options to retrieve those jar files bdm-dao.jar and bdm-model.jar:

- Maybe the simplest way is, from a Studio, create any Rest API extension (even a dummy one): it will install for you the jar files inside:&nbsp;/home/YOUR\_USER/.m2/repository/com/company/model/...
- See answer of this question:&nbsp;[http://community.ofelia.com/questions-and-answers/error-trying-get-transportrequestdao-javalangclassnotfoundexception](http://community.ofelia.com/questions-and-answers/error-trying-get-transportrequestdao-javalangclassnotfoundexception)

Hope this helps,

Emmanuel

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/community_bonitasoft/original/2X/6/6b7b18c0478f2645369e82e009b65e3b97f2cc12.svg) [@system](https://community.ofelia.com/u/system)\
**Post date:** [29 December 2015 10:33 UTC](https://community.ofelia.com/t/access-a-business-data-object-using-the-java-api-v-7-1-4/6793/6 "2015-12-29T10:33:35Z")

</div>

From which context do you access the Java Engine API?

For example in Bonita BPM Groovy script you have DAO object that let you access business data objects.

---

<div class="post-metadata">

**Author:** ![ephemeris.lappis](https://avatars.discourse-cdn.com/v4/letter/e/76d3ee/32.png) [@ephemeris.lappis](https://community.ofelia.com/u/ephemeris.lappis)\
**Post date:** [29 December 2015 10:47 UTC](https://community.ofelia.com/t/access-a-business-data-object-using-the-java-api-v-7-1-4/6793/7 "2015-12-29T10:47:12Z")

</div>

Hello.

I’m using the Java API for an external access from our ESB (ServiceMix), not inside the process itself.

The Java API let me access all the processes and tasks data and operations, but I’ve not found any working way to get their associated business data objects.

I’ve tried the BusinessDataAPI. Somthing like that, where “p” is a ProcessInstance.

BusinessDataAPI businessDataAPI = TenantAPIAccessor.getBusinessDataAPI(session);  
List dataReferences = businessDataAPI.getProcessBusinessDataReferences(p.getId(), 0, Integer.MAX\_VALUE);  
System.out.println(“\>\>\> Data of process " + p.getId());  
for (BusinessDataReference dr : dataReferences) {  
System.out.println(” \> " + dr.getName() + " / " + dr.getType());  
}

But an exception is thrown :

## Exception in thread “main” com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$UnknownFieldException: No such field org.bonitasoft.engine.business.data.impl.SimpleBusinessDataReferenceImpl.storageIdAsString ---- Debugging information ---- field : storageIdAsString class : org.bonitasoft.engine.business.data.impl.SimpleBusinessDataReferenceImpl required-type : org.bonitasoft.engine.business.data.impl.SimpleBusinessDataReferenceImpl converter-type : com.thoughtworks.xstream.converters.reflection.ReflectionConverter path : /list/org.bonitasoft.engine.business.data.impl.SimpleBusinessDataReferenceImpl/storageIdAsString line number : 7 class[1] : java.util.ArrayList converter-type[1] : com.thoughtworks.xstream.converters.collections.CollectionConverter version : null

```
at org.bonitasoft.engine.api.HTTPServerAPI.invokeMethod(HTTPServerAPI.java:143)
at org.bonitasoft.engine.api.impl.ClientInterceptor.invoke(ClientInterceptor.java:88)
at com.sun.proxy.$Proxy5.getProcessBusinessDataReferences(Unknown Source)
at my.tests.bonita.t1.Test1.main(Test1.java:88)
at < ========== Beginning of the server stack trace ========== >. ( )
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.determineType(AbstractReflectionConverter.java:453)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:294)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:234)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:71)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.addCurrentElementToCollection(CollectionConverter.java:79)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:72)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:66)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.unmarshal(CollectionConverter.java:61)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1052)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1024)
at com.thoughtworks.xstream.XStream$2.readFromStream(XStream.java:1716)
at com.thoughtworks.xstream.core.util.CustomObjectInputStream.readObjectOverride(CustomObjectInputStream.java:104)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:365)
at org.bonitasoft.engine.api.HTTPServerAPI.fromXML(HTTPServerAPI.java:257)
at org.bonitasoft.engine.api.HTTPServerAPI.checkInvokeMethodReturn(HTTPServerAPI.java:152)
at org.bonitasoft.engine.api.HTTPServerAPI.invokeMethod(HTTPServerAPI.java:136)
at org.bonitasoft.engine.api.impl.ClientInterceptor.invoke(ClientInterceptor.java:88)
at com.sun.proxy.$Proxy5.getProcessBusinessDataReferences(Unknown Source)
at my.tests.bonita.t1.Test1.main(Test1.java:88)

```

Any idea about this exception, or another way of retrieving data from ProcessInstance ?

Thanks again.

Regards.

---

<div class="post-metadata">

**Author:** ![ephemeris.lappis](https://avatars.discourse-cdn.com/v4/letter/e/76d3ee/32.png) [@ephemeris.lappis](https://community.ofelia.com/u/ephemeris.lappis)\
**Post date:** [29 December 2015 11:26 UTC](https://community.ofelia.com/t/access-a-business-data-object-using-the-java-api-v-7-1-4/6793/8 "2015-12-29T11:26:22Z")

</div>

Hello.  
Your answer is a bit surprising !  
What does the BusinessDataAPI actually does or aims to do ?  
The REST API seems no to be so easy to integrate, and needs wrapping code while the Java API is ready to use.  
Is there an example of business data access in Java code using any of the APIs ?  
Thanks again.

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/community_bonitasoft/original/2X/6/6b7b18c0478f2645369e82e009b65e3b97f2cc12.svg) [@system](https://community.ofelia.com/u/system)\
**Post date:** [8 January 2016 13:26 UTC](https://community.ofelia.com/t/access-a-business-data-object-using-the-java-api-v-7-1-4/6793/9 "2016-01-08T13:26:39Z")

</div>

Actually I was wrong and I just update my answer with a solution to use BusinessDataAPI to get the business variable information of a process instance (id of the instance is static in my example: 2) and DAO to get the actual value of the variable.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![amitroyes3](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@amitroyes3](https://community.ofelia.com/u/amitroyes3)\
**Post date:** [15 January 2016 06:06 UTC](https://community.ofelia.com/t/access-a-business-data-object-using-the-java-api-v-7-1-4/6793/10 "2016-01-15T06:06:39Z")

</div>

hello ,  
i tried same code and i have this error

result = businessDataAPI.getProcessBusinessDataReferences(pendingTask.getParentProcessInstanceId(), 0, 100);  
BusinessObjectDAOFactory daoFactory = new BusinessObjectDAOFactory();  
SurgeryDAO sD = daoFactory.createDAO(session, SurgeryDAO.class);  
SimpleBusinessDataReference sbdr=(SimpleBusinessDataReference)result[0];

```
		try{
			 Surgery ks= sD.findByPersistenceId(sbdr.getStorageId())
		 
		}catch(Exception e){
		
		}

```

WARNING: Exception or error caught in server resource  
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:  
C:\BonitaBPMSubscription-7.1.0\workspace\tomcat\bonita\client\tenants\1\work\pages\custompage\_datasource\Peningtask.groovy: 21: unable to resolve class com.company.model.SurgeryDAO  
@ line 21, column 1.  
import com.company.model.SurgeryDAO;  
^

C:\BonitaBPMSubscription-7.1.0\workspace\tomcat\bonita\client\tenants\1\work\pages\custompage\_datasource\Peningtask.groovy: 20: unable to resolve class com.company.model.Surgery  
@ line 20, column 1.  
import com.company.model.Surgery;  
^

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/community_bonitasoft/original/2X/6/6b7b18c0478f2645369e82e009b65e3b97f2cc12.svg) [@system](https://community.ofelia.com/u/system)\
**Post date:** [18 January 2016 08:01 UTC](https://community.ofelia.com/t/access-a-business-data-object-using-the-java-api-v-7-1-4/6793/11 "2016-01-18T08:01:03Z")

</div>

Your Business Object definition (the Java class `com.company.model.SurgeryDAO`) is packaged in the `bdm-model.jar` and required DAO implementation is packaged in `bdm-dao.jar`.

So you need to includes those to JAR files in your application classloader.

You can get those jar files in `client-bdm.zip`file located in `BonitaBPMCommunity-7.1.5/workspace/tomcat/bonita/engine-server/work/tenants/1/data-management-client` (when Studio is running)

---

<div class="post-metadata">

**Author:** ![pedrociarlini](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/pedrociarlini/32/833_2.png) [@pedrociarlini](https://community.ofelia.com/u/pedrociarlini)\
**Post date:** [24 April 2020 18:21 UTC](https://community.ofelia.com/t/access-a-business-data-object-using-the-java-api-v-7-1-4/6793/12 "2020-04-24T18:21:51Z")

</div>

Hi everyone. Thanks for your answer, Antoine.

I'm trying to do the same on Bonita Studio **7.10.3**.

At this version, the **bdm-dao.jar** and **bdm-model.jar** files appears to be missing with these names. I found at "\<BonitaStudio\>/workspace/tomcat/server/temp/bonita\_engine\_\<bla\>@\<ble\>.local/platform/classloaders/local/TENANT/1/\<some hex-number\>" the file named "BDR.jar.nnnn.jar", with "Entity\*\*DAOImpl", "Entity\*\*DAO" and "Entity\*\*" classes.

This is the way for this version?

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/community_bonitasoft/original/2X/6/6b7b18c0478f2645369e82e009b65e3b97f2cc12.svg) [@system](https://community.ofelia.com/u/system)\
**Post date:** [25 January 2016 10:08 UTC](https://community.ofelia.com/t/access-a-business-data-object-using-the-java-api-v-7-1-4/6793/13 "2016-01-25T10:08:25Z")

</div>

Can you share all your project files so I can take a look and maybe figure out the issue?

Also please reply using the “Add new comment” link below as you are not posting a new answer to the original question.

---

<div class="post-metadata">

**Author:** ![amitroyes3](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@amitroyes3](https://community.ofelia.com/u/amitroyes3)\
**Post date:** [27 January 2016 09:59 UTC](https://community.ofelia.com/t/access-a-business-data-object-using-the-java-api-v-7-1-4/6793/14 "2016-01-27T09:59:48Z")

</div>

## pending task groovy

import groovy.json.JsonBuilder;  
import groovy.sql.Sql;

import java.util.logging.Logger;

import javax.naming.Context;  
import javax.naming.InitialContext;  
import javax.servlet.http.HttpServletRequest;  
import javax.servlet.http.HttpServletResponse;  
import javax.sql.DataSource;

import org.bonitasoft.console.common.server.page._;  
import org.bonitasoft.engine.api._;  
import org.bonitasoft.engine.bdm.\*;  
import org.bonitasoft.engine.bpm.flownode.ActivityInstanceCriterion;  
import org.bonitasoft.engine.bpm.flownode.HumanTaskInstance;  
import org.bonitasoft.engine.business.data.SimpleBusinessDataReference;  
import org.bonitasoft.engine.session.APISession;

import com.company.model.KneeSurgery;  
import com.company.model.KneeSurgeryDAO;  
//import com.company.model.KneeSurgeryDAO;

class Peningtask implements RestApiController {

```
RestApiResponse doHandle(HttpServletRequest request, PageResourceProvider pageResourceProvider, PageContext pageContext, RestApiResponseBuilder apiResponseBuilder, RestApiUtil restApiUtil) {
	 List<HumanTaskInstance> pendingTasks= new ArrayList();
	 List result=new ArrayList();
	 final LoginAPI loginAPI = TenantAPIAccessor.getLoginAPI();
	 
	 
 //System.out.println("login with install//install");
 final APISession session = pageContext.getApiSession();
 
/*	final ProcessAPI processAPI = TenantAPIAccessor.getProcessAPI();
	final List<HumanTaskInstance> pendingTasks =processAPI.getPendingHumanTaskInstances(3,
		0, 20, ActivityInstanceCriterion.PRIORITY_ASC);*/

```

// System.out.println("Pending tasks for user " + session.getUserName() + ": " + pendingTasks);

```
	try{
		
	
	final ProcessAPI processAPI=TenantAPIAccessor.getProcessAPI(session);
	pendingTasks =processAPI.getAssignedHumanTaskInstances(session.getUserId(),
		0, 20, ActivityInstanceCriterion.PRIORITY_ASC);
	
	//buildErrorResponse(apiResponseBuilder, "getProcessInstance="+processAPI.getProcessInstance(pendingTask.getParentProcessInstanceId()).toString(), restApiUtil.logger);
	for ( HumanTaskInstance pendingTask : pendingTasks) {
		buildErrorResponse(apiResponseBuilder, "For loop="+processAPI.getProcessInstance(pendingTask.getParentProcessInstanceId()).toString(), restApiUtil.logger);
		
			BusinessDataAPI businessDataAPI = TenantAPIAccessor.getBusinessDataAPI(session);
			result = businessDataAPI.getProcessBusinessDataReferences(pendingTask.getParentProcessInstanceId(), 0, 100);
			BusinessObjectDAOFactory daoFactory = new BusinessObjectDAOFactory();
			KneeSurgeryDAO ksD = daoFactory.createDAO(session, KneeSurgeryDAO.class);
			SimpleBusinessDataReference sbdr=(SimpleBusinessDataReference)result[0];
			buildErrorResponse(apiResponseBuilder, "SimpleBusinessDataReference="+sbdr, restApiUtil.logger);
		
		//KneeSurgery ks = KneeSurgeryDAO.findByPersistenceId
		try{
			 KneeSurgery ks= ksD.findByPersistenceId(sbdr.getStorageId())
		 buildErrorResponse(apiResponseBuilder, "KneeSurgery="+ks, restApiUtil.logger);
		}catch(Exception e){
		buildErrorResponse(apiResponseBuilder, "Kneesurgery Error="+e.getMessage(), restApiUtil.logger);
		continue;
		}
		 //findByPersistenceId(sbdr.getStorageId());
					//	KneeSurgeryDAO ks=
		//processAPI.getProcessDataInstance("kneeReplacementInput",pendingTask.parentProcessInstanceId);
		//AccessorUtil.getQueryDefinitionAPI().getProcessDataField(uuid,varName)
		buildErrorResponse(apiResponseBuilder, "result="+result, restApiUtil.logger);
		}
		
	
	
	}catch(Exception e){
		return buildErrorResponse(apiResponseBuilder, "Error="+e.getMessage(), restApiUtil.logger)
	}
	//System.out.println("logged out");
	
		
	 /*
	
	String queryId = request.getParameter "queryId"
	if (queryId == null) {
		return buildErrorResponse(apiResponseBuilder, "the parameter queryId is missing",restApiUtil.logger)
	}
	String query = getQuery queryId, pageResourceProvider
	if (query == null) {
		return buildErrorResponse(apiResponseBuilder, "the queryId does not refer to an existing query", restApiUtil.logger)
	}
	Map<String, String> params = getSqlParameters request
	Sql sql = buildSql pageResourceProvider*/
	try {
		def rows =pendingTasks+result;//"hello world";// params.isEmpty() ? sql.rows(query) : sql.rows(query, params)
		JsonBuilder builder = new JsonBuilder(rows)
		String table = builder.toPrettyString()
		return buildResponse(apiResponseBuilder, table)
	} finally {
	   // sql.close()
	}
}

protected RestApiResponse buildErrorResponse(RestApiResponseBuilder apiResponseBuilder, String message, Logger logger ) {
	logger.severe message

	Map<String, String> result = [:]
	result.put "error", message
	apiResponseBuilder.withResponseStatus(HttpServletResponse.SC_BAD_REQUEST)
	buildResponse apiResponseBuilder, result
}

protected RestApiResponse buildResponse(RestApiResponseBuilder apiResponseBuilder, Serializable result) {
	apiResponseBuilder.with {
		withResponse(result)
		build()
	}
}

```

}

* * *

displayName=Rest API extension - Generic DataSource  
name=custompage\_datasource  
description=Rest API extension - Generic DataSource

#zip is a rest api extension  
contentType=apiExtension

#list of api extension in zip  
apiExtensions = datasource

datasource.method = GET  
datasource.pathTemplate = pendingtask  
datasource.classFileName = Peningtask.groovy  
datasource.permissions = demoPermission

* * *

pom.xml

4.0.0  
org.bonitasoft.example  
rest-api-sql-datasource  
1.0-SNAPSHOT  
jar  
  
\<bonita.version\>7.0.1\</bonita.version\>  
\<groovy.version\>2.4.3-01\</groovy.version\>  
  
  
  
maven-restlet  
Public online Restlet repository  
[http://maven.restlet.com](http://maven.restlet.com)  
  
  
  
  
javax.servlet  
servlet-api  
2.5  
provided  
  
  
org.bonitasoft.engine  
bonita-client  
${bonita.version}  
compile

```
	<dependency>
		<groupId>org.bonitasoft.engine</groupId>
		<artifactId>bonita-server</artifactId>
		<version>7.1.5</version>
	</dependency>

	<!-- test -->
	<dependency>
		<groupId>org.restlet.jse</groupId>
		<artifactId>org.restlet</artifactId>
		<version>2.1.7</version>
		<scope>test</scope>
	</dependency>
	<!-- <dependency> <groupId>org.spockframework</groupId> <artifactId>spock-core</artifactId> 
		<version>0.7-groovy-1.8</version> <scope>test</scope> </dependency> -->

	<dependency>
		<groupId>org.spockframework</groupId>
		<artifactId>spock-core</artifactId>
		<version>1.0-groovy-2.4</version>
	</dependency>

	<dependency> <!-- enables mocking of classes (in addition to interfaces) -->
		<groupId>cglib</groupId>
		<artifactId>cglib-nodep</artifactId>
		<version>2.2</version>
		<scope>test</scope>
	</dependency>
	<dependency> <!-- enables mocking of classes without default constructor (together with 
			CGLIB) -->
		<groupId>org.objenesis</groupId>
		<artifactId>objenesis</artifactId>
		<version>1.2</version>
		<scope>test</scope>
	</dependency>

	<!--........................................................... -->

	<dependency>
		<groupId>org.bonitasoft.bdm</groupId>
		<artifactId>bdm-client-pojo</artifactId>
		<version>0.0.2-SNAPSHOT</version>
		<scope>system</scope>
		<systemPath>C:\BonitaBPMSubscription-7.1.0\workspace\BonitaCareCoordination\lib</systemPath>
	</dependency>
	<dependency>
		<groupId>org.bonitasoft.bdm</groupId>
		<artifactId>bdm-model</artifactId>
		<version>0.0.2-SNAPSHOT</version>
		<scope>system</scope>
		<systemPath>D:/bdm-model.jar</systemPath>
	</dependency>
	<dependency>
		<groupId>org.javassist</groupId>
		<artifactId>javassist</artifactId>
		<version>3.18.1-GA</version>
	</dependency>
	<dependency>
		<groupId>org.bonitasoft.engine</groupId>
		<artifactId>bonita-client</artifactId>
		<version>7.1.4</version>
	</dependency>

	<!-- .......................................................... -->
</dependencies>

<build>
	<finalName>${project.artifactId}</finalName>
	<resources>
		<resource>
			<directory>src/main/resources</directory>
		</resource>
	</resources>

	<sourceDirectory>src/main/groovy</sourceDirectory>
	<testSourceDirectory>src/test/groovy</testSourceDirectory>

	<plugins>

		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-compiler-plugin</artifactId>
			<version>3.3</version>
			<configuration>
				<source>1.7</source>
				<target>1.7</target>
				<compilerId>groovy-eclipse-compiler</compilerId>
			</configuration>
			<dependencies>
				<dependency>
					<groupId>org.codehaus.groovy</groupId>
					<artifactId>groovy-eclipse-compiler</artifactId>
					<version>2.9.2-01</version>
				</dependency>
				<dependency>
					<groupId>org.codehaus.groovy</groupId>
					<artifactId>groovy-eclipse-batch</artifactId>
					<version>${groovy.version}</version>
				</dependency>
			</dependencies>
		</plugin>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-assembly-plugin</artifactId>
			<version>2.4.1</version>
			<executions>
				<execution>
					<id>page-content</id>
					<phase>package</phase>
					<goals>
						<goal>single</goal>
					</goals>
					<inherited>false</inherited>
					<configuration>
						<ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
						<appendAssemblyId>false</appendAssemblyId>
						<descriptors>
							<descriptor>content.xml</descriptor>
						</descriptors>
					</configuration>
				</execution>
			</executions>
		</plugin>
	</plugins>
</build>

```

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/community_bonitasoft/original/2X/6/6b7b18c0478f2645369e82e009b65e3b97f2cc12.svg) [@system](https://community.ofelia.com/u/system)\
**Post date:** [27 January 2016 10:03 UTC](https://community.ofelia.com/t/access-a-business-data-object-using-the-java-api-v-7-1-4/6793/15 "2016-01-27T10:03:53Z")

</div>

Can you please share all that using Dropbox or Google Drive?

That is not really readable when posted in the forum.

Thanks
