In about 60% cases can not resolve JavaDelegate in Service after Timer


#13

I didn’t said in the context of changing the package name. The input which I gave you was need to map the delegate class in the service task


#14

@aravindhrs, I’m sorry, but I have lost. Let’s try again.
I have class:

package com.example.camunda.createrequest;

import com.example.service.RequestService;
import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class DeleteDraftRequestDelegate implements JavaDelegate {

    private final RequestService requestService;

    @Autowired
    public DeleteDraftRequestDelegate(RequestService requestService) {
        this.requestService = requestService;
    }

    @Override
    public void execute(DelegateExecution delegateExecution) throws Exception {
        String businessKey = delegateExecution.getProcessBusinessKey();
        log.info("Delete draft request with business key #{} ", businessKey);
        Long requestId = Long.valueOf(businessKey);
        requestService.deleteDraft(requestId);
    }
}

I have two instances and in 50% cases all works fine.


#15

Unfortunately, it has another cluster… On the conference describing heterogeneous cluster, on the other hand I have homogeneous cluster.


#16

diagram_1.bpmn (2.6 KB)

check the service task configured in attached bpmn.

It should be com.example.camunda.createrequest.DeleteDraftRequestDelegate


#17

Hi @romankh3,

I don’t think that you have a homogeneous cluster. From the description above and the fact that you are facing a ClassNotFoundException, this class is only available in one of your spring-boot applications.

For me it seems that you have a heterogeneous cluster.

But you can extract the delegation logic into a seperate project and use this in both spring-boot applications.

Hope this helps, Ingo


#18

@Ingo_Richtsmeier, I think it because of the reason that I have two instances of the same application. They are the same so they have the same JavaDelegates.

Am I wrong?


#19

@aravindhrs, I checked, it is like you wrote.


#20

Did you create both spring-boot apps with the same pom.xml?


#21

@Ingo_Richtsmeier, yes it’s one spring-boot app, which has two instances,
so yes. it has the same pom.xml, too.


#22

OK, then my assumption was wrong. Sorry for insisting.


#23

Don’t worry about it. Thanks for your time and attention to help me.


#24

@romankh3 I was able to reproduce the issue. This issue will occur when you change the package name or moving the java delegates to another package after initiating the process instance.

Seems you have deployed your bpmn. At that moment lets say for example your java delegate DeleteDraftRequestDelegate is in the package called com.foo. And workflow was initiated in that moment, so in service task you configured as com.foo.DeleteDraftRequestDelegate. it will works fine. And the process instance is still active.

Now, you just moved the DeleteDraftRequestDelegate to new package called com.bar and also service task config looks like com.bar.DeleteDraftRequestDelegate. This configuration also will work fine only for newly launched process instances. But old process instances which are launched still referring to the delegates in this package com.foo. So thats why you are getting this class not found exception.

So you need to migrate your process to newer version of workflow deployemnt or else terminate the old running instances or ignore it.

Newly launched process instances will work fine. Old process instances will fail, new process instances will succeed the execution.


#25

Hello @aravindhrs!
I got your point, but I don’t think that it’s related to my case, because of the reason that I redeploy every hour my instances and process instances are dropping before deploy.


#26

@romankh3 if you move the class to other package, for those running instances it will give classnotfound exception. remaining everything looks fine in your process


#27

Hi @romankh3,

if your Java class (or Spring bean) only exists in one of the two projects, make sure you configure the job executor to be deployment aware. Otherwise you might end up in a situation where the job executor of the application that does not have access to the class tries to execute the timer job and fails loading that class.

You can read more about this topic here:

https://docs.camunda.org/manual/7.10/user-guide/spring-boot-integration/configuration/#camunda-engine-properties

https://docs.camunda.org/manual/7.10/user-guide/process-engine/the-job-executor/#job-execution-in-heterogeneous-clusters

Cheers,
Ben


#28

Hi @benhoffmann!

if your Java class (or Spring bean) only exists in one of the two projects

It’s not my case, because of the reason, that I have two instances of the one application. So Am I right that this is not a Heterogeneous Cluster, it’s a homogeneous cluster?

I don’t know important it is or not, but I have Camunda-Cockpit app, where I’m checking processes.

Best regards,
Roman B.


#29

How do you run Cockpit? If that is a separate application (e.g. a third Spring Boot app), this could be the cause. It could be that you have a setup running where Cockpit actually tries to fetch jobs, too.


#30

I run Cockpit as a SpringBoot app, without any logic in an application. It’s app just for monitoring workflow processes.
Cockpit app has next dependencies:

        <dependency>
            <groupId>org.camunda.bpm.springboot</groupId>
            <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
        </dependency>

        <!-- Required to use Spin dataformat support -->
        <dependency>
            <groupId>org.camunda.spin</groupId>
            <artifactId>camunda-spin-dataformat-all</artifactId>
        </dependency>
        <dependency>
            <groupId>org.camunda.bpm</groupId>
            <artifactId>camunda-engine-plugin-spin</artifactId>
        </dependency>

        <dependency>
            <groupId>org.camunda.bpm.springboot</groupId>
            <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
        </dependency>

Can it be a trigger for this trouble?


#31

Jep, that is most likely the one that causes your problems. You should disable the job executor for that application completely since you only use it for monitoring. Also, if you don’t need the REST API, you can remove that dependency.


#32

Thanks, @benhoffmann!
You were right!

In total I want to write about it for other people:

I have a case, when I have Camunda-Cockpit Spring boot app, just for monitoring the business process.

And I have Spring-boot App with Camunda engine, where I have BPMN process.

It’s a heterogeneous cluster and JobExecutor, which triggers ProcessInstance after timer tries to find in Camunda-Cockpit app and Doesn’t find it at all. For this case, I get class not found exception

Thanks for all(@aravindhrs, @Niall, @Ingo_Richtsmeier, @benhoffmann), who helped me to understand the situation!

The solution was to disable JobExecutor at all by providing property in application.properties. Camunda has property for this case.

I hope it will help other people. If someone has a question, don’t hesitate to ask me on this topic or private message.


ENGINE-09017 Cannot load class JavaDelegate for homogeneous cluster[RESOLVED]