Bug 1310439 - RuntimeManagerFactory may fail to initialize in OSGi
Summary: RuntimeManagerFactory may fail to initialize in OSGi
Keywords:
Status: CLOSED EOL
Alias: None
Product: JBoss BRMS Platform 6
Classification: Retired
Component: Fuse Integration
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
medium
high
Target Milestone: ER2
: 6.3.0
Assignee: Edson Tirelli
QA Contact: Marek Winkler
Petr Penicka
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-02-21 15:53 UTC by Marek Winkler
Modified: 2020-03-27 20:11 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-03-27 20:11:32 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Marek Winkler 2016-02-21 15:53:55 UTC
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:
always

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 16:02:26 UTC
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 17:09:14 UTC
Marek,

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.

P.S.
is there anywhere that reproducer or wasn't it yet created?

Comment 3 Marek Winkler 2016-03-15 13:30:30 UTC
Maciej,

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 15:04:10 UTC
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 13:02:37 UTC
Verified in BRMS 6.3.0 ER2.


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