[
https://issues.jboss.org/browse/DROOLS-3869?page=com.atlassian.jira.plugi...
]
Anton Giertli commented on DROOLS-3869:
---------------------------------------
More details:
- Camel on EAP (Fuse 7.2.0 + EAP 7.1.x)
- RHDM 7.0.0 - 7.3.0 (I've tried all the versions)
Drools API is invoked in a Bean, which is part of the camel route. The bean includes
following code:
~~~
KieServices ks = KieServices.Factory.get();
~~~
KieServices are entry point to the Drools API. Unfortunately, this code, as is, returns
null - which means any further API calls are not possible from this point on.
There are two workarounds to this issue:
# Instantiate KieServices using 'new' keyword
#
KieServices ksDirect = new KieServicesImpl();
However, this breaks the contract since KieServices should really be a singleton.
# Change thread context classloader (TCCL):
~~~
// Workaround due to classloading issues
ClassLoader prevTCL = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(RuleRepository.class.getClassLoader());
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId(groupId, artifactid, version);
container = ks.newKieContainer(releaseId);
scanner = ks.newKieScanner(container);
Thread.currentThread().setContextClassLoader(prevTCL); // end of workaround
~~~
This works fine, but it's considered as a hack.
Reproducer is attached. Instructions are these:
~~~
- Install Fuse 7.2 on EAP - no further changes to installation are needed
https://access.redhat.com/documentation/en-us/red_hat_fuse/7.2/html/insta...
- Start the instance
- Extract my app and execute 'mvn clean install' - this will automatically deploy
it onto eap/wildfly
- GET
http://127.0.0.1:8080/rest/reproducer/execute
You should see following response in the server.log:
18:30:26,409 INFO [stdout] (default task-2) KS is null
Which means KieServices are null, hence I cannot proceed with operations such as loading
the KJAR etc.
In reproducer, the app flow goes from:
RESTBuilder -> Hello.java -> sampleMethod
~~~
ServiceDiscovery doesn't work with Fuse
---------------------------------------
Key: DROOLS-3869
URL:
https://issues.jboss.org/browse/DROOLS-3869
Project: Drools
Issue Type: Bug
Components: core engine
Reporter: Mario Fusco
Assignee: Mario Fusco
Priority: Major
Attachments: reproducer.zip
--
This message was sent by Atlassian Jira
(v7.12.1#712002)