camunda-community-hub / camunda-platform-7-reactor

Event Driven process applications
https://camunda.github.io/camunda-bpm-reactor/
Apache License 2.0
80 stars 34 forks source link

Unable to register plugin when using Camunda + Tomcat Deployment #103

Open harjsing opened 4 years ago

harjsing commented 4 years ago

Hi, I am unable to register the ReactorProcessEnginePlugin due to a missing default constructor.

It was added at some point in this commit and later removed (probably because of migration to using source eventbus)? #45

Error:

    at org.camunda.bpm.engine.impl.util.EngineUtilLogger.exceptionWhileInstantiatingClass(EngineUtilLogger.java:78)
    at org.camunda.bpm.engine.impl.util.ReflectUtil.instantiate(ReflectUtil.java:192)
    at org.camunda.bpm.container.impl.deployment.StartProcessEngineStep.createInstance(StartProcessEngineStep.java:154)
    at org.camunda.bpm.container.impl.deployment.StartProcessEngineStep.configurePlugins(StartProcessEngineStep.java:134)
    at org.camunda.bpm.container.impl.deployment.StartProcessEngineStep.performOperationStep(StartProcessEngineStep.java:100)
    at org.camunda.bpm.container.impl.spi.DeploymentOperation.execute(DeploymentOperation.java:116)
    ... 17 more
Caused by: java.lang.InstantiationException: org.camunda.bpm.extension.reactor.plugin.ReactorProcessEnginePlugin
    at java.lang.Class.newInstance(Class.java:427)
    at org.camunda.bpm.engine.impl.util.ReflectUtil.instantiate(ReflectUtil.java:189)
    ... 21 more
Caused by: java.lang.NoSuchMethodException: org.camunda.bpm.extension.reactor.plugin.ReactorProcessEnginePlugin.<init>()
    at java.lang.Class.getConstructor0(Class.java:3082)
    at java.lang.Class.newInstance(Class.java:412)
    ... 22 more

Using version: 2.1.2

Thanks!

harjsing commented 4 years ago

@jangalinski Thoughts?

jangalinski commented 4 years ago

Time is the issue .. :-)

I get the problem ... so we should have a default constructor that internally creates a new instance of the bus and delegates to the current constructor. Easy.

But then you have to make sure, that your consumers use the same bus. So you must not create a new CamundaEventBus in your app but instead get the instance from the process engine configuration. That would work.

Would you like to provide a PR?

harjsing commented 4 years ago

Thanks @jangalinski

I got an instance of the CamundaEventBus like so:

CamundaEventBus eventBus = CamundaReactor.eventBus(processEngineShim.getProcessEngine());  //ProcessEngine (default)

TaskListener listener = new CustomTaskListener(eventBus);

and a simple TaksListener as follows


@CamundaSelector(type = "userTask", event = TaskListener.EVENTNAME_CREATE)
public class CustomTaskListener implements TaskListener {

    public CustomTaskListener(CamundaEventBus bus) {
        bus.register(this);
    }

    public void notify(DelegateTask delegateTask) {
    }
}

I can successfully see the notify being called :-)

I'll submit a PR soon!