# Use java object

**URL:** <https://community.ofelia.com/t/use-java-object/4018>\
**Category:** Q&A\
**Created:** [11 December 2013 09:37 UTC](https://community.ofelia.com/t/use-java-object/4018 "2013-12-11T09:37:44Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![box](https://avatars.discourse-cdn.com/v4/letter/b/b19c9b/32.png) [@box](https://community.ofelia.com/u/box)\
**Post date:** [11 December 2013 09:37 UTC](https://community.ofelia.com/t/use-java-object/4018/1 "2013-12-11T09:37:44Z")

</div>

Hi all,

I'm trying to set member of&nbsp;a Java Object like this

---

package pro.bonita;

import java.io.Serializable;

public class OpSum implements Serializable {

&nbsp; &nbsp; private static final long serialVersionUID = -7285183091396405846L;

private int a;

private int b;

&nbsp; &nbsp; public int getA() {

&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return a;

&nbsp;&nbsp; &nbsp;}

&nbsp;&nbsp; &nbsp;public void setA(int a) {

&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;this.a = a;

&nbsp;&nbsp; &nbsp;}

&nbsp;&nbsp; &nbsp;public int getB() {

&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return b;

&nbsp;&nbsp; &nbsp;}

&nbsp;&nbsp; &nbsp;public void setB(int b) {

&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;this.b = b;

&nbsp;&nbsp; &nbsp;}

}

---

in my simple test Process App.

I followed the steps described at&nbsp;http://harx.nl/create-complex-data-objects-for-bonitasoft-bpms/

In BOS 5.6 works.

Now, I'm trying to do the same thing with BOS 6.1like in figure&nbsp;

https://drive.google.com/file/d/0BwiZdFAlfhs3V2t4NUlvSUo3U28/edit?usp=sharing

Don't work because (Bonita BPM engine log)

at .Caused By:(data opSum does not exist in the context 7 ACTIVITY\_INSTANCE

I understand that I have to instantiate it. But where and how?

Sorry for my bad english & thanks in advance.

Regards

Alessandro

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![thomas.allweyer](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/thomas.allweyer/32/891_2.png) [@thomas.allweyer](https://community.ofelia.com/u/thomas.allweyer)\
**Post date:** [12 December 2013 10:35 UTC](https://community.ofelia.com/t/use-java-object/4018/2 "2013-12-12T10:35:09Z")

</div>

You can instantiate the java object when you define the process variable (usually in the pool). Use a groovy script for the default value. In that script create and return a new object.

---

<div class="post-metadata">

**Author:** ![box](https://avatars.discourse-cdn.com/v4/letter/b/b19c9b/32.png) [@box](https://community.ofelia.com/u/box)\
**Post date:** [13 December 2013 11:17 UTC](https://community.ofelia.com/t/use-java-object/4018/3 "2013-12-13T11:17:49Z")

</div>

Thank you.

PS.&nbsp;This is a difference with the version 5.x or am I wrong?

&nbsp;

---

<div class="post-metadata">

**Author:** ![zafdo](https://avatars.discourse-cdn.com/v4/letter/z/e274bd/32.png) [@zafdo](https://community.ofelia.com/u/zafdo)\
**Post date:** [17 December 2013 23:45 UTC](https://community.ofelia.com/t/use-java-object/4018/4 "2013-12-17T23:45:30Z")

</div>

I tried to do it but during evaluation I get error like &nbsp;unable to resolve class or Unable to deserialize object \<object-stream\>

---

<div class="post-metadata">

**Author:** ![box](https://avatars.discourse-cdn.com/v4/letter/b/b19c9b/32.png) [@box](https://community.ofelia.com/u/box)\
**Post date:** [18 December 2013 09:03 UTC](https://community.ofelia.com/t/use-java-object/4018/5 "2013-12-18T09:03:55Z")

</div>

This is my script that set default value

import pro.bonita.\*;  
def opSum = new OpSum();  
opSum.a=0;  
opSum.b=0;  
return opSum;

&nbsp;

---

<div class="post-metadata">

**Author:** ![paul33](https://avatars.discourse-cdn.com/v4/letter/p/5f8ce5/32.png) [@paul33](https://community.ofelia.com/u/paul33)\
**Post date:** [18 April 2014 12:00 UTC](https://community.ofelia.com/t/use-java-object/4018/6 "2014-04-18T12:00:04Z")

</div>

I’ve got the same issue, does anyone has a clue on where this might come from ?

---

<div class="post-metadata">

**Author:** ![box](https://avatars.discourse-cdn.com/v4/letter/b/b19c9b/32.png) [@box](https://community.ofelia.com/u/box)\
**Post date:** [19 April 2014 05:27 UTC](https://community.ofelia.com/t/use-java-object/4018/7 "2014-04-19T05:27:59Z")

</div>

[https://www.youtube.com/watch?v=xJ5lVljCu3k](https://www.youtube.com/watch?v=xJ5lVljCu3k)

I hope to help you

Regards

---

<div class="post-metadata">

**Author:** ![paul33](https://avatars.discourse-cdn.com/v4/letter/p/5f8ce5/32.png) [@paul33](https://community.ofelia.com/u/paul33)\
**Post date:** [28 April 2014 16:06 UTC](https://community.ofelia.com/t/use-java-object/4018/8 "2014-04-28T16:06:29Z")

</div>

Thank you ! that’s it !
