Bug 1144151 - [Kie-Camel in Fuse] KieContainer should work by Classloader scope instead of JVM scope
Summary: [Kie-Camel in Fuse] KieContainer should work by Classloader scope instead of ...
Keywords:
Status: CLOSED EOL
Alias: None
Product: JBoss BRMS Platform 6
Classification: Retired
Component: BRE
Version: 6.0.2
Hardware: Unspecified
OS: Unspecified
medium
unspecified
Target Milestone: ER3
: 6.2.0
Assignee: Mario Fusco
QA Contact: Lukáš Petrovický
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-09-18 19:24 UTC by Alessandro Lazarotti
Modified: 2023-09-14 02:47 UTC (History)
7 users (show)

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


Attachments (Terms of Use)
tpl-kiedemo (13.46 KB, application/zip)
2014-10-31 17:32 UTC, Alessandro Lazarotti
no flags Details
tpl-kiedemo2 (13.56 KB, application/zip)
2014-10-31 17:33 UTC, Alessandro Lazarotti
no flags Details
Reproducer updated to Drools 6.3.0.CR2 and Fuse 6.2.0 (11.49 KB, application/zip)
2015-09-04 09:05 UTC, Marek Winkler
no flags Details
Reproducer (tpl-kiedemo2) updated to Drools 6.3.0.CR2 and Fuse 6.2.0 (11.54 KB, application/zip)
2015-09-04 11:00 UTC, Marek Winkler
no flags Details

Description Alessandro Lazarotti 2014-09-18 19:24:51 UTC
Kie API should allow KieContainer to be created by each OSGI bundle using KieCamel. Usually bundles have different and independent solutions deployed, so we need a different instance of KieContainer to each one.

Currently if tried to deploy two bundles that uses KieCamel to create KieContainer, the result will be:

------
java.lang.IllegalStateException: There's already another KieContainer
created from a different ClassLoader
          at
org.drools.compiler.kie.builder.impl.KieServicesImpl.getKieClasspathContainer(KieServicesImpl.java:74) 
------

Comment 6 Mario Fusco 2014-10-30 12:02:27 UTC
I cannot reproduce this problem since, for what I can see, this has been already fixed also on 6.0.x branch with this commit

https://github.com/droolsjbpm/droolsjbpm-integration/commit/99ea65b52dd6817660cb9f4bb0c9291c3d54a101

This means that either the release used to reproduce the problem is too old and doesn't contain that fix or there's another way to still reproduce the same issue that at the moment I cannot find. 

In the first case I think that this ticket could be closed, while if the problem is still present I'd need a reproducer to further investigate it.

Comment 7 Alessandro Lazarotti 2014-10-30 12:10:53 UTC
Mario do you know since which release this fix was supposed to be fixed ?

Comment 8 Mario Fusco 2014-10-30 14:06:29 UTC
This has been fixed in 6.0.1.Final release. Please let me know which version the customer who reported the problem is using.

Comment 9 Alessandro Lazarotti 2014-10-31 17:32:34 UTC
Created attachment 952561 [details]
tpl-kiedemo

Comment 10 Alessandro Lazarotti 2014-10-31 17:33:05 UTC
Created attachment 952562 [details]
tpl-kiedemo2

Comment 16 jvahala 2015-01-28 15:26:19 UTC
Reproduced. 

Exception "java.lang.IllegalStateException: There's already another KieContainer
created from a different ClassLoader"
is no longer here. 

After adding both profiles into container I've got this: 

[pool-kiedemo-0.0.1-thread-2] ERROR org.apache.camel.blueprint.BlueprintCamelContext - Error occurred during starting Camel: CamelContext(sol-poc-kiedemo) due Failed to create route POCKIEDEMO-park at: >>> To[kie:ksession2?action=insertBody] <<< in route: Route(POCKIEDEMO-park)[[From[seda:park]] -> [SetBody[simple{... because of Failed to resolve endpoint: kie://ksession2?action=insertBody due to: Cannot lookup: ksession2 from registry: org.apache.camel.blueprint.BlueprintContainerRegistry@1c9303dd with expected type: interface org.kie.api.runtime.CommandExecutor due: Error when instantiating bean ksession2 of class class org.kie.aries.blueprint.factorybeans.KieObjectsFactoryBean
org.apache.camel.FailedToCreateRouteException: Failed to create route POCKIEDEMO-park at: >>> To[kie:ksession2?action=insertBody] <<< in route: Route(POCKIEDEMO-park)[[From[seda:park]] -> [SetBody[simple{... because of Failed to resolve endpoint: kie://ksession2?action=insertBody due to: Cannot lookup: ksession2 from registry: org.apache.camel.blueprint.BlueprintContainerRegistry@1c9303dd with expected type: interface org.kie.api.runtime.CommandExecutor due: Error when instantiating bean ksession2 of class class org.kie.aries.blueprint.factorybeans.KieObjectsFactoryBean
	at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:912)
	at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:177)
	at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:778)
	at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1959)
	at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1709)
	at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1583)
	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
	at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1551)
	at org.apache.camel.blueprint.BlueprintCamelContext.start(BlueprintCamelContext.java:177)
	at org.apache.camel.blueprint.BlueprintCamelContext.maybeStart(BlueprintCamelContext.java:209)
	at org.apache.camel.blueprint.BlueprintCamelContext.serviceChanged(BlueprintCamelContext.java:147)
	at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:934)
	at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:795)
	at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:544)
	at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4666)
	at org.apache.felix.framework.Felix.registerService(Felix.java:3674)
	at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:347)
	at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:353)
	at org.apache.camel.blueprint.BlueprintCamelContext.init(BlueprintCamelContext.java:97)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:297)
	at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:958)
	at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:712)
	at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:824)
	at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)
	at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)
	at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)
	at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)
	at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:676)
	at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:374)
	at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:261)
	at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:270)
	at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:233)
	at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)
	at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)
	at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)
	at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)
	at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)
	at org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1103)
	at org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:696)
	at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:484)
	at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4650)
	at org.apache.felix.framework.Felix$4.run(Felix.java:2123)
	at org.apache.felix.framework.Felix$5.run(Felix.java:2167)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: kie://ksession2?action=insertBody due to: Cannot lookup: ksession2 from registry: org.apache.camel.blueprint.BlueprintContainerRegistry@1c9303dd with expected type: interface org.kie.api.runtime.CommandExecutor due: Error when instantiating bean ksession2 of class class org.kie.aries.blueprint.factorybeans.KieObjectsFactoryBean
	at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:531)
	at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:71)
	at org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:192)
	at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:106)
	at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:112)
	at org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:61)
	at org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:55)
	at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:500)
	at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:213)
	at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:909)
	... 53 more
Caused by: org.apache.camel.NoSuchBeanException: Cannot lookup: ksession2 from registry: org.apache.camel.blueprint.BlueprintContainerRegistry@1c9303dd with expected type: interface org.kie.api.runtime.CommandExecutor due: Error when instantiating bean ksession2 of class class org.kie.aries.blueprint.factorybeans.KieObjectsFactoryBean
	at org.apache.camel.impl.CompositeRegistry.lookupByNameAndType(CompositeRegistry.java:58)
	at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookupByNameAndType(PropertyPlaceholderDelegateRegistry.java:63)
	at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookup(PropertyPlaceholderDelegateRegistry.java:82)
	at org.kie.camel.component.KieEndpoint.configure(KieEndpoint.java:152)
	at org.kie.camel.component.KieEndpoint.<init>(KieEndpoint.java:114)
	at org.kie.camel.component.KieComponent.createEndpoint(KieComponent.java:56)
	at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:123)
	at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:511)
	... 62 more
Caused by: org.osgi.service.blueprint.container.ComponentDefinitionException: Error when instantiating bean ksession2 of class class org.kie.aries.blueprint.factorybeans.KieObjectsFactoryBean
	at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:315)
	at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:806)
	at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)
	at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)
	at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)
	at org.apache.aries.blueprint.container.BlueprintRepository.createInstance(BlueprintRepository.java:230)
	at org.apache.aries.blueprint.container.BlueprintRepository.create(BlueprintRepository.java:145)
	at org.apache.aries.blueprint.container.BlueprintContainerImpl.getComponentInstance(BlueprintContainerImpl.java:754)
	at org.apache.camel.blueprint.BlueprintContainerRegistry.lookupByNameAndType(BlueprintContainerRegistry.java:54)
	at org.apache.camel.impl.CompositeRegistry.lookupByNameAndType(CompositeRegistry.java:52)
	... 69 more
Caused by: java.lang.IncompatibleClassChangeError: Found interface org.mvel2.asm.FieldVisitor, but class was expected
	at org.drools.core.rule.builder.dialect.asm.ClassGenerator$FieldDescr.write(ClassGenerator.java:350)
	at org.drools.core.rule.builder.dialect.asm.ClassGenerator.generateBytecode(ClassGenerator.java:127)
	at org.drools.compiler.rule.builder.dialect.asm.ASMConsequenceStubBuilder.createConsequenceBytecode(ASMConsequenceStubBuilder.java:31)
	at org.drools.compiler.rule.builder.dialect.asm.AbstractASMConsequenceBuilder.build(AbstractASMConsequenceBuilder.java:26)
	at org.drools.compiler.rule.builder.RuleBuilder.build(RuleBuilder.java:118)
	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.addRule(KnowledgeBuilderImpl.java:1715)
	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.compileRules(KnowledgeBuilderImpl.java:1021)
	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.compileAllRules(KnowledgeBuilderImpl.java:899)
	at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildRules(CompositeKnowledgeBuilderImpl.java:301)
	at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildPackages(CompositeKnowledgeBuilderImpl.java:107)
	at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:91)
	at org.drools.compiler.kie.builder.impl.AbstractKieModule.buildKnowledgePackages(AbstractKieModule.java:219)
	at org.drools.compiler.kie.builder.impl.KieContainerImpl.createKieBase(KieContainerImpl.java:403)
	at org.drools.compiler.kie.builder.impl.KieContainerImpl.getKieBase(KieContainerImpl.java:363)
	at org.kie.aries.blueprint.factorybeans.KieObjectsResolver.resolveKBase(KieObjectsResolver.java:38)
	at org.kie.aries.blueprint.factorybeans.KieObjectsResolver.newStatelessSession(KieObjectsResolver.java:75)
	at org.kie.aries.blueprint.factorybeans.KieObjectsFactoryBean.createKieSession(KieObjectsFactoryBean.java:73)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:297)
	at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:958)
	at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:313)
	... 80 more


there is still chance that I am doing something wrong, but I did same steps with old version and the new one. 

Moving back to Assigned

Comment 17 Alessandro Lazarotti 2015-09-01 00:11:51 UTC
By the last comment from Jiri this is reproducible now, so I am removing the NEED_INFO.

Comment 18 jvahala 2015-09-01 12:57:50 UTC
Mario,

here is step by step what I do to reproduce this issue on fuse 6.2.0.

Take original reproducer Kiedemo and build it. 
download fuse 6.2.0, open folder and then: 
$ ./bin/fuse
$ fabric:create (in fuse console, create admin)
--- restart fuse --- 
 then insert all commands from readme file in original Kiedemo reproducer. (starts with fabric:profile-delete --force tpl-kiedemo)
then go to localhost:8181, log in
-> containers -> create -> (from profiles) chose Tpl -> kiedemo -> create and start container -> see expcetion: 

Provision Exception:
org.osgi.service.resolver.ResolutionException: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=camel-core; type=karaf.feature; filter:="(&(osgi.identity=camel-core)(type=karaf.feature))"
  at org.apache.felix.resolver.Candidates.populateResource(Candidates.java:285)
  at org.apache.felix.resolver.Candidates.populate(Candidates.java:153)
  at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:148)
  at io.fabric8.agent.region.SubsystemResolver.resolve(SubsystemResolver.java:190)
  at io.fabric8.agent.service.Deployer.deploy(Deployer.java:255)
  at io.fabric8.agent.service.Agent.provision(Agent.java:348)
  at io.fabric8.agent.service.Agent.provision(Agent.java:194)
  at io.fabric8.agent.DeploymentAgent.doUpdate(DeploymentAgent.java:642)
  at io.fabric8.agent.DeploymentAgent$2.run(DeploymentAgent.java:256)
  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
  at java.util.concurrent.FutureTask.run(FutureTask.java:262)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
  at java.lang.Thread.run(Thread.java:745)

I will try that on FUSE 6.0.x where I reproduced it originally

Comment 19 Marek Winkler 2015-09-04 09:05:38 UTC
Created attachment 1070187 [details]
Reproducer updated to Drools 6.3.0.CR2 and Fuse 6.2.0

Attaching the reproducer (only the first one) updated to use Drools 6.3.0.CR2 and Fuse 6.2.0.GA.

Please be aware that drools-karaf-features.xml in 6.3.0.CR2 declares a duplicate 'kie-remote-client' feature; you need to correct it manually by editing the artifact in your local Maven repo or use a different version. Not sure if manual correction in the local Maven repo does not get overriden when Fuse is connected to the internet (I managed to start the container when I was offline, then you need to have all the dependencies in your local Maven repo).

Aligning versions should be easier now, since the reproducer instructions (see readme_edit file) have been updated to use features instead of enumerating all bundles.

I managed to deploy this into Fuse 6.2.0 (620133 version) and connect to the trigger URL [1] that printed out 'TEST BODY'. When you are creating a new Fabric container, you might need to set it to use not only tpl-kiedemo profile, but also jboss-fuse-full profile - I ran into some random issues with Camel not being available when not having this profile added.

Hope this helps, please let me know if the reproducer did not work for you.

[1] http://localhost:8080/kiedemo/trigger

Comment 20 Marek Winkler 2015-09-04 11:00:37 UTC
Created attachment 1070214 [details]
Reproducer (tpl-kiedemo2) updated to Drools 6.3.0.CR2 and Fuse 6.2.0

Attaching the reproducer (the second one) updated to use Drools 6.3.0.CR2 and Fuse 6.2.0.GA. Please note I had to change the port which tpl-kiedemo2 is binding to, as it was in conflict with the first reproducer (tpl-kiedemo).

I managed to deploy both reproducers (tpl-kiedemo and tpl-kiedemo2) into Fuse 6.2.0 (620133 version) without problems. Next, I hit the trigger URLs [1], [2] that printed out 'TEST BODY'. I have double checked in logs of both Fabric containers that the expected rule had fired.

To sum it up, I am unable to reproduce the problem anymore on Drools 6.3.0.CR2 combined with 1.2.0-SNAPSHOT Integration Pack (kie-camel) and Fuse 6.2.0.GA (620133), both applications seem to work correctly.

Regarding the reproducers, I'd suggest to use pre-defined features from drools-karaf-features.xml, as it is much more maintainable and convenient way of importing Drools/jBPM artifacts into an OSGi container, than importing particular bundles by hand.

[1] http://localhost:8080/kiedemo/trigger
[2] http://localhost:8081/kiedemo2/trigger

Comment 21 Mario Fusco 2015-09-04 12:02:44 UTC
Since Marek checked that it works on Drools 6.3.0.CR2 I'm flagging this as modified.

Comment 22 jvahala 2015-10-16 14:53:45 UTC
Verified with 6.3.0.Final-redhat-1 version

Comment 24 Red Hat Bugzilla 2023-09-14 02:47:53 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 1000 days


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