cancel
Showing results for 
Search instead for 
Did you mean: 

Static member is set to null by the process engine

sor1
Champ in-the-making
Champ in-the-making
Hello,
I have a static member:
public final class MySingletonClass
{
    public static MyClass MyUniqueObject;
}
MyClass is a class extending the interface Com4jObject.

I need to use this static object in 2 service tasks of my workflow: the first service task create it and start to use it. The second service task also use it (and dispose it).
I cannot set this object as a process variable as it is not serializable (com object).
My problem is that my static object is randomly set to null before I try to access it in the second service task.

Why is this static member set to null and how would you do solve this problem?

Thanks.
11 REPLIES 11

frederikherema1
Star Contributor
Star Contributor
That is correct. If the (timer) job is executed on activiti explorer, instead of in "your" app"s JVM. This explains why the static variable is null.

To overcome this, either use another -more robust mechanism- to share state (DB) or make sure your app runs in the same tomcat/JVM.

jbarrez
Star Contributor
Star Contributor
Yes of course…

If you start the process from a jar and continue it in a webapplication … these are two different JVM's. Which *of course* will mean static values will have different values. JVM's can't sniff those kind of things (not do we want them to). That's pretty much Java 101.

That's also the reason why we invented process variables which are stored in the database…