# Java Classloading problem

**URL:** <https://forum.camunda.io/t/java-classloading-problem/3139>\
**Category:** Discussion & Questions\
**Tags:** process-engine\
**Created:** [March 21, 2017, 5:59pm UTC](https://forum.camunda.io/t/java-classloading-problem/3139 "2017-03-21T17:59:27Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![lsantaniello](https://forum.camunda.io/user_avatar/forum.camunda.io/lsantaniello/32/10420_2.png) [@lsantaniello](https://forum.camunda.io/u/lsantaniello)\
**Post date:** [March 21, 2017, 5:59pm UTC](https://forum.camunda.io/t/java-classloading-problem/3139/1 "2017-03-21T17:59:27Z")

</div>

Hi guys, I need to support for this scenario. I describe the stept to explain my problem. Could you please help me?

1. I have a first.war that contains

- hello1.bpmn (User Task, Service Task 1, User Task)
- hello.java - linked to service task 1 with log a simple message “Hello mom”

1. I have a second.war that contains

- hello2.bpmn (User Task, Service Task 1, User Task, Service Task 2)
- hello.java - linked to service task 1 with log a simple message “Hello dad”
- byebye.java - linked to service task 1 with log a simple message “Hello kevin”

1. I deploy a first.war

2. I start 3 instances

3. camunda create 3 process instances

4. I claim and I complete a first user task and a service task 1 will be runned. I see “Hello mom” into log

5. ATTENTION!!! I deploy second.war

6. I claim and I complete a first user task and a service task 1 will be runned. I see “Hello dad” into log.  
I waited to see “Hello mom” but I see “Hello dad”. JAVA CLASS OVERRIDED

How Can I isolate the package?

Regards  
Luca

---

<div class="post-metadata">

**Author:** ![thorben](https://forum.camunda.io/user_avatar/forum.camunda.io/thorben/32/78_2.png) [@thorben](https://forum.camunda.io/u/thorben)\
**Post date:** [March 22, 2017, 8:06am UTC](https://forum.camunda.io/t/java-classloading-problem/3139/2 "2017-03-22T08:06:28Z")

</div>

Hi Luca,

Do the BPMN processes `hello1` and `hello2` have different IDs (i.e. in the XML)?

Cheers,  
Thorben

---

<div class="post-metadata">

**Author:** ![lsantaniello](https://forum.camunda.io/user_avatar/forum.camunda.io/lsantaniello/32/10420_2.png) [@lsantaniello](https://forum.camunda.io/u/lsantaniello)\
**Post date:** [March 22, 2017, 8:34am UTC](https://forum.camunda.io/t/java-classloading-problem/3139/3 "2017-03-22T08:34:34Z")

</div>

No, The ID is the same, I changed only Version Tag

---

<div class="post-metadata">

**Author:** ![thorben](https://forum.camunda.io/user_avatar/forum.camunda.io/thorben/32/78_2.png) [@thorben](https://forum.camunda.io/u/thorben)\
**Post date:** [March 22, 2017, 8:51am UTC](https://forum.camunda.io/t/java-classloading-problem/3139/4 "2017-03-22T08:51:06Z")

</div>

Camunda’s mechanism for registering applications with prior process deployments is by default based on the IDs. See [https://docs.camunda.org/manual/7.6/user-guide/process-applications/the-processes-xml-deployment-descriptor/#process-application-deployment](https://docs.camunda.org/manual/7.6/user-guide/process-applications/the-processes-xml-deployment-descriptor/#process-application-deployment) for a details. The application server log should also show relevant entries when you deploy the second WAR.

You can try giving the deployments distinct names (use the `name` attribute of the `process-archive` element in `processes.xml`) and set the `resumeBy` property to `deployment-name`.

Cheers,  
Thorben

---

<div class="post-metadata">

**Author:** ![lsantaniello](https://forum.camunda.io/user_avatar/forum.camunda.io/lsantaniello/32/10420_2.png) [@lsantaniello](https://forum.camunda.io/u/lsantaniello)\
**Post date:** [March 22, 2017, 9:01am UTC](https://forum.camunda.io/t/java-classloading-problem/3139/5 "2017-03-22T09:01:49Z")

</div>

Thank. Only one note: I use Camunda 7.5 Release. Do This release use the same approch?

Tks

---

<div class="post-metadata">

**Author:** ![thorben](https://forum.camunda.io/user_avatar/forum.camunda.io/thorben/32/78_2.png) [@thorben](https://forum.camunda.io/u/thorben)\
**Post date:** [March 22, 2017, 9:05am UTC](https://forum.camunda.io/t/java-classloading-problem/3139/6 "2017-03-22T09:05:13Z")

</div>

Yup, should work the same there.

---

<div class="post-metadata">

**Author:** ![garysamuelson](https://forum.camunda.io/user_avatar/forum.camunda.io/garysamuelson/32/579_2.png) [@garysamuelson](https://forum.camunda.io/u/garysamuelson)\
**Post date:** [March 22, 2017, 1:30pm UTC](https://forum.camunda.io/t/java-classloading-problem/3139/7 "2017-03-22T13:30:45Z")

</div>

For model versions ([filename].bpmn), Thorben mentioned above, Camunda does support concurrent, multi-version execution. In-other-words, you could start a process per one if its many versions. And, a process version shouldn’t jump (or self upgrade) unless specifically directed to do so.

Regarding calling on the specific Java class versions: a few options -

1. Wouldn’t Java naming (CDI) and inheritance (extends) work?

Have a base class define your core behaviour. For example class HelloBase manages core methods required of all descendants. Then, extend this class to a new type HelloExtendedV1, give it an appropriate name such as @Named(“helloExtendedV1”), and use this in hello1.bpmn model.

For hello2.bpmn (model), we also extend HelloBase but give it a different _class_ name such as HelloExtendedV2 and _name_ it @Named(“helloExtendedV2”). Now you have two distinct  
class types/versions, with appropriate class and CDI names - essentially allowing reuse of base behaviour with opportunities for extension per model version requirements.

1. Java interfaces provide similar features - but, going at the problem with a different angle. I was thinking of a factory pattern whereby an instance is created per specific model requirements. In this way you could logically call on specific implementations per model or task-instance requirements.

2. Aspect Oriented Programming? This approach cross-cuts classes, looking for specific “concerns” (i.e. business requirements), and assembles them per expressed configuration and application.  
see: [JBoss documentation](https://docs.jboss.org/aop/1.0/aspect-framework/userguide/en/html/what.html) (briefly - there are likely more detailed words on this). Case management, alongside a document-oriented approach, follows this methodology. Meaning that the Case model (CMMN) definition provides very specific features per business requirements… as they are defined by [user/subject, object-document](http://garysamuelson.com/blog/wp-content/uploads/2015/02/2016-01-30_12h05_21.png), and predicate (task) requirements.

3. Forgot to mention OSGi - this provides very tight controls on class loading. Excellent fit for BPM/Case. But, this can be somewhat complicated.

NOTE: Apologies for shamelessly linking to my blog…

---

<div class="post-metadata">

**Author:** ![etavolaro](https://forum.camunda.io/letter_avatar_proxy/v4/letter/e/ecae2f/32.png) [@etavolaro](https://forum.camunda.io/u/etavolaro)\
**Post date:** [March 22, 2017, 2:18pm UTC](https://forum.camunda.io/t/java-classloading-problem/3139/8 "2017-03-22T14:18:58Z")

</div>

@garysamuelson,  
clear your points and the options you are explained about.  
The pattern suggested can be the solution to have process instances coexistence and belonging to different process definitions. In the use case @lsantaniello showed, it is supposed to be used the class loader isolation of a process engine application (packaged usuallly as a .war) and then it seems like this mechanism is “overriden” by Camunda deployment registration where the last loaded resources win in the .classes loading.  
My point is, this is an not desidered behavior from my side and has the following downside:

1. whereas process definition version is managed for you by Camunda, this is not the case for .classes.
2. Very often we need to have at max two ot three process definition coexisting in the same Camunda Container, and we need to deploy, as @lsantaniello said, first.war and second.war, where second.war (based on the pattern suggested) need to provide HelloExtendedV1.java and aldo HelloExtendedV2.java (all descendants of the HelloBaseClass used so far by all process istances belonging to the different process version supported);
3. based on the 1) and 2) points we need also to take care of, at a some point in the time (for sure after the hot deployment of the second.war is completed), to delete first.war before a Camunda container restart, because is not guaranteed in which order the .wars are loaded, and a Class Not Exception can occurs if first.war is loaded as last durint the startup;

Can We definitely say Camunda does not support class loading isolation for same process engine applications with process definition with same id?

What about for third library when we need to update them because a well know bug was solved and but we cannot have the chance to apply this pattern?

Thanks  
Elmiro

---

<div class="post-metadata">

**Author:** ![garysamuelson](https://forum.camunda.io/user_avatar/forum.camunda.io/garysamuelson/32/579_2.png) [@garysamuelson](https://forum.camunda.io/u/garysamuelson)\
**Post date:** [March 23, 2017, 12:33pm UTC](https://forum.camunda.io/t/java-classloading-problem/3139/9 "2017-03-23T12:33:38Z")

</div>

> [@etavolaro](#):
>
> support class loading isolation for same process engine

Sounds like you need OSGi or a micro-service pattern - thinking in terms of utilizing boundaries established by SCA/SwitchYard, ReST, WS interfaces (etc).

Camunda provides the _flexibility supporting the necessary pattern_ per your requirements (tight class-loading controls) - as a BPM/Case engine should.

We’re now taking a closer look at service-implementation (application server) _patterns supporting modularity_: OSGi and micro-service?

Not sure if this information helps - [a while ago I spent some time on OSGi](http://garysamuelson.com/blog/?p=774). Micro-services though looks like the emerging leader.

My concern though is the complexity associated with managing versions, configuration, and complex deployments.

---

<div class="post-metadata">

**Author:** ![thorben](https://forum.camunda.io/user_avatar/forum.camunda.io/thorben/32/78_2.png) [@thorben](https://forum.camunda.io/u/thorben)\
**Post date:** [March 23, 2017, 12:47pm UTC](https://forum.camunda.io/t/java-classloading-problem/3139/10 "2017-03-23T12:47:36Z")

</div>

> [@etavolaro](#):
>
> Can We definitely say Camunda does not support class loading isolation for same process engine applications with process definition with same id?

Did you try out what I wrote here? [Java Classloading problem - #4 by thorben](https://forum.camunda.io/t/java-classloading-problem/3139/4)

---

<div class="post-metadata">

**Author:** ![system](https://forum.camunda.io/uploads/default/original/3X/5/8/58d50142eacca605d35cb1ef9e6b86ae85f49436.png) [@system](https://forum.camunda.io/u/system)\
**Post date:** [January 30, 2024, 10:49am UTC](https://forum.camunda.io/t/java-classloading-problem/3139/11 "2024-01-30T10:49:37Z")

</div>

Closed on January 30, 2024, 10:49am UTC


