Bug 1310439 - RuntimeManagerFactory may fail to initialize in OSGi
RuntimeManagerFactory may fail to initialize in OSGi
Product: JBoss BRMS Platform 6
Classification: JBoss
Component: Fuse Integration (Show other bugs)
Unspecified Unspecified
medium Severity high
: ER2
: 6.3.0
Assigned To: Maciej Swiderski
Marek Winkler
Petr Penicka
Depends On:
  Show dependency treegraph
Reported: 2016-02-21 10:53 EST by Marek Winkler
Modified: 2016-04-01 09:02 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Marek Winkler 2016-02-21 10:53:55 EST
Description of problem:

If RuntimeManagerFactory [1] initialization fails, any subsequent call to Factory.get() will fail. However, in OSGi environment, KIE-API bundle might have been initialized before jBPM Runtime manager bundle was installed - in that case, even if you installed jbpm feature later, RuntimeManager still fails to initialize. The only way to make KIE-API reinitialize RuntimeManager is to restart KIE-API bundle.

When debugging [1], it turned out that property Factory.initialized is set to true even when the initialization fails (even if it was for a different ClassLoader parameter) and there is no way to initialize it again (except restarting the bundle). 

[1] https://github.com/droolsjbpm/droolsjbpm-knowledge/blob/master/kie-api/src/main/java/org/kie/api/runtime/manager/RuntimeManagerFactory.java#L104

Version-Release number of selected component (if applicable):
BRMS 6.2.1
Fuse 6.2.1

How reproducible:

Steps to Reproduce:
1. install jbpm bundle
2. attempt to initialize RuntimeManagerFactory in your app bundle

I will provide a unit test reproducer later.

Actual results:
RuntimeManagerFactory fails to initialize and RuntimeManagerFactory.Factory.get() returns null.

Expected results:
RuntimeManagerFactory reattempts to initialize.
Comment 1 Marek Winkler 2016-02-21 11:02:26 EST
I would not mind if this behaviour occurred strictly when you install 'kie-api' and then later 'jbpm' features. What puzzles me is that the problem occurs also when you install just 'jbpm' feature.
Comment 2 Maciej Swiderski 2016-03-14 13:09:14 EDT

so this happens when you install jbpm feature without kie api? Not sure I fully understood the problem...

We could provide reset method on RuntimeManagerFactory which would put it back to initial state. Would this be valid solution?

I'd like to avoid any more advanced logic as that could lead to unexpected runtime consequences.

is there anywhere that reproducer or wasn't it yet created?
Comment 3 Marek Winkler 2016-03-15 09:30:30 EDT

sorry for not having this described in more detail. 

The test case (org.drools.karaf.itest.RuntimeManagerFeatureKarafIntegrationTest) can be found in [1], sorry for the delay with the reproducer. It was also caused by the fact that I was unable to reproduce the original behaviour - let me summarize the problem:

1. user installs drools-module feature - it includes kie-api, drools, but not jBPM,

2. user attempts to obtain a jBPM service from the KIE-API, e.g. RuntimeManagerFactory using "RuntimeManagerFactory.Factory.get()", which returns null (no jBPM installed, so this behaves as expected),

3. user installs jbpm feature,

4. user calls "RuntimeManagerFactory.Factory.get()" again, which should now succeed, but it does not; instead, it throws the following exception:

  java.lang.RuntimeException: RuntimeManagerFactory was not initialized, see previous errors

Unfortunately, I was unable to reproduce the original problem I had when I installed jbpm feature only and encountered this exception - maybe I had made a mistake somewhere at that time (or there is a nasty race condition which I was unable to reproduce now).

Hope this makes it clear, sorry for not being specific enough in the initial description.

[1] https://github.com/droolsjbpm/droolsjbpm-integration/pull/357
Comment 4 Petr Široký 2016-03-15 11:04:10 EDT
I believe we are already using very similar approach in Drools, namely for ProcessBuilderFactory and ProcessRuntimeFactory.

See https://github.com/droolsjbpm/drools/commit/b28fd0a2b and https://github.com/droolsjbpm/jbpm/commit/da31bb30a90a

The factories are being forcefully re-initialized from jBPM Activators.
Comment 6 Marek Winkler 2016-04-01 09:02:37 EDT
Verified in BRMS 6.3.0 ER2.

Note You need to log in before you can comment on or make changes to this bug.