<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Instantiation of org.drools.concurrent.ExecutorProviderImpl in OSGi
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/tkleszczynski">Tomasz KleszczyƄski</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/758994#758994">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hello everybody,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span>I've prepared simple process which uses some rules. There is small problem during invocation - one of class cannot be loaded correctly. I found the same problem in </span><a class="jive-link-external-small" href="http://lists.jboss.org/pipermail/rules-users/2012-May/026839.html" target="_blank">http://lists.jboss.org/pipermail/rules-users/2012-May/026839.html</a><span> but in that thread there was not correct solution</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>During invocation on OSGi environment I've got following problem:</p><ol><li style="text-align: start;">org.drools.concurrent.ExecutorProviderFactory$ExecutorProviderHolder tries to obtain instance of class org.drools.concurrent.ExecutorProvider using org.drools.util.ServiceRegistryImpl.get method</li><li style="text-align: start;">org.drools.util.ServiceRegistryImpl doesn't have any implementation of org.drools.concurrent.ExecutorProvider in it's registry</li><li style="text-align: start;">org.drools.util.ServiceRegistryImpl tries to instantiate default implementation - org.drools.concurrent.ExecutorProviderImpl using org.drools.util.ServiceRegistryImpl$ReflectionInstantiator using wrong classloader - in my opinion there is problem.</li><li style="text-align: start;">Finally java.lang.ClassNotFoundException: org.drools.concurrent.ExecutorProviderImpl is thrown because classloader from bundle knowledge-api-5.4.0.Final cannot load class org.drools.concurrent.ExecutorProviderImpl.</li></ol><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This type of problems in OSGi environment were solved by registering proper instances in OSGi service repository. For example for core module in org.drools.osgi.core.Activator class. Maybe would be worth to register also org.drools.concurrent.ExecutorProviderImpl as OSGi service. I've tried to fix this problem this and this way solves this problem.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Stacktrace I've got in this situation.</p><p>SEVERE: Unable to start blueprint container for bundle jbpm5-example-client</p><p>org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to intialize bean sampleProcessClient</p><p>&#160;&#160;&#160; at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:710)</p><p>&#160;&#160;&#160; at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:820)</p><p>&#160;&#160;&#160; at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:783)</p><p>&#160;&#160;&#160; at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)</p><p>&#160;&#160;&#160; at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)</p><p>&#160;&#160;&#160; at java.util.concurrent.FutureTask.run(FutureTask.java:138)</p><p>&#160;&#160;&#160; at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)</p><p>&#160;&#160;&#160; at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)</p><p>&#160;&#160;&#160; at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)</p><p>&#160;&#160;&#160; at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:648)</p><p>&#160;&#160;&#160; at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:340)</p><p>&#160;&#160;&#160; at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:242)</p><p>&#160;&#160;&#160; at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)</p><p>&#160;&#160;&#160; at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)</p><p>&#160;&#160;&#160; at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)</p><p>&#160;&#160;&#160; at java.util.concurrent.FutureTask.run(FutureTask.java:138)</p><p>&#160;&#160;&#160; at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)</p><p>&#160;&#160;&#160; at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)</p><p>&#160;&#160;&#160; at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)</p><p>&#160;&#160;&#160; at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)</p><p>&#160;&#160;&#160; at java.lang.Thread.run(Thread.java:662)</p><p>Caused by: java.lang.ExceptionInInitializerError</p><p>&#160;&#160;&#160; at org.drools.concurrent.ExecutorProviderFactory.getExecutorProvider(ExecutorProviderFactory.java:12)</p><p>&#160;&#160;&#160; at org.drools.rule.constraint.MvelConstraint$ExecutorHolder.&lt;clinit&gt;(MvelConstraint.java:208)</p><p>&#160;&#160;&#160; at org.drools.rule.constraint.MvelConstraint.jitEvaluator(MvelConstraint.java:199)</p><p>&#160;&#160;&#160; at org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:164)</p><p>&#160;&#160;&#160; at org.drools.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:124)</p><p>&#160;&#160;&#160; at org.drools.reteoo.AlphaNode.modifyObject(AlphaNode.java:154)</p><p>&#160;&#160;&#160; at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateModifyObject(CompositeObjectSinkAdapter.java:507)</p><p>&#160;&#160;&#160; at org.drools.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(CompositeObjectSinkAdapter.java:432)</p><p>&#160;&#160;&#160; at org.drools.reteoo.ObjectTypeNode.modifyObject(ObjectTypeNode.java:314)</p><p>&#160;&#160;&#160; at org.drools.reteoo.EntryPointNode.modifyObject(EntryPointNode.java:265)</p><p>&#160;&#160;&#160; at org.drools.common.NamedEntryPoint.update(NamedEntryPoint.java:470)</p><p>&#160;&#160;&#160; at org.drools.common.NamedEntryPoint.update(NamedEntryPoint.java:370)</p><p>&#160;&#160;&#160; at org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:317)</p><p>&#160;&#160;&#160; at org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:312)</p><p>&#160;&#160;&#160; at org.foo.jbpm5.drools.rules.pricing.Rule_Pricing_based_on_demand____Used_AUDI_70__of_the_original_price_77e52c0333d54b068cd3bc5e98c79344.defaultConsequence(Rule_Pricing_based_on_demand____Used_AUDI_70__of_the_original_price_77e52c0333d54b068cd3bc5e98c79344.java:8)</p><p>&#160;&#160;&#160; at org.foo.jbpm5.drools.rules.pricing.Rule_Pricing_based_on_demand____Used_AUDI_70__of_the_original_price_77e52c0333d54b068cd3bc5e98c79344DefaultConsequenceInvokerGenerated.evaluate(Unknown Source)</p><p>&#160;&#160;&#160; at org.foo.jbpm5.drools.rules.pricing.Rule_Pricing_based_on_demand____Used_AUDI_70__of_the_original_price_77e52c0333d54b068cd3bc5e98c79344DefaultConsequenceInvoker.evaluate(Unknown Source)</p><p>&#160;&#160;&#160; at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1273)</p><p>&#160;&#160;&#160; at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1209)</p><p>&#160;&#160;&#160; at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1442)</p><p>&#160;&#160;&#160; at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)</p><p>&#160;&#160;&#160; at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)</p><p>&#160;&#160;&#160; at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)</p><p>&#160;&#160;&#160; at org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:295)</p><p>&#160;&#160;&#160; at org.foo.jbpm5.drools.DefineCarPriceWorkItemHandler.executeWorkItem(DefineCarPriceWorkItemHandler.java:24)</p><p>&#160;&#160;&#160; at org.drools.process.instance.impl.DefaultWorkItemManager.internalExecuteWorkItem(DefaultWorkItemManager.java:70)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:105)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:124)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerNodeInstance(NodeInstanceImpl.java:205)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:164)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.impl.ExtendedNodeInstanceImpl.triggerCompleted(ExtendedNodeInstanceImpl.java:47)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.node.StateBasedNodeInstance.triggerCompleted(StateBasedNodeInstance.java:162)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.node.StateBasedNodeInstance.triggerCompleted(StateBasedNodeInstance.java:143)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.node.WorkItemNodeInstance.triggerCompleted(WorkItemNodeInstance.java:239)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.node.WorkItemNodeInstance.workItemCompleted(WorkItemNodeInstance.java:301)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.node.WorkItemNodeInstance.signalEvent(WorkItemNodeInstance.java:277)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.signalEvent(WorkflowProcessInstanceImpl.java:326)</p><p>&#160;&#160;&#160; at org.drools.process.instance.impl.DefaultWorkItemManager.completeWorkItem(DefaultWorkItemManager.java:116)</p><p>&#160;&#160;&#160; at org.foo.jbpm5.drools.RankCarWorkItemHandler.executeWorkItem(RankCarWorkItemHandler.java:27)</p><p>&#160;&#160;&#160; at org.drools.process.instance.impl.DefaultWorkItemManager.internalExecuteWorkItem(DefaultWorkItemManager.java:70)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:105)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:124)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerNodeInstance(NodeInstanceImpl.java:205)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:164)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.node.StartNodeInstance.triggerCompleted(StartNodeInstance.java:49)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.node.StartNodeInstance.internalTrigger(StartNodeInstance.java:41)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:124)</p><p>&#160;&#160;&#160; at org.jbpm.ruleflow.instance.RuleFlowProcessInstance.internalStart(RuleFlowProcessInstance.java:35)</p><p>&#160;&#160;&#160; at org.jbpm.process.instance.impl.ProcessInstanceImpl.start(ProcessInstanceImpl.java:188)</p><p>&#160;&#160;&#160; at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.start(WorkflowProcessInstanceImpl.java:303)</p><p>&#160;&#160;&#160; at org.jbpm.process.instance.ProcessRuntimeImpl.startProcessInstance(ProcessRuntimeImpl.java:168)</p><p>&#160;&#160;&#160; at org.drools.common.AbstractWorkingMemory.startProcessInstance(AbstractWorkingMemory.java:1092)</p><p>&#160;&#160;&#160; at org.drools.impl.StatefulKnowledgeSessionImpl.startProcessInstance(StatefulKnowledgeSessionImpl.java:330)</p><p>&#160;&#160;&#160; at org.foo.jbpm5.example.client.SampleProcessClient.startStatelessDroolsEvaluation(SampleProcessClient.java:59)</p><p>&#160;&#160;&#160; at org.foo.jbpm5.example.client.SampleProcessClient.init(SampleProcessClient.java:48)</p><p>&#160;&#160;&#160; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)</p><p>&#160;&#160;&#160; at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)</p><p>&#160;&#160;&#160; at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)</p><p>&#160;&#160;&#160; at java.lang.reflect.Method.invoke(Method.java:597)</p><p>&#160;&#160;&#160; at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:238)</p><p>&#160;&#160;&#160; at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:954)</p><p>&#160;&#160;&#160; at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:708)</p><p>&#160;&#160;&#160; ... 20 more</p><p>Caused by: java.lang.IllegalArgumentException: Unable to instantiate service for Class 'org.drools.concurrent.ExecutorProvider'</p><p>&#160;&#160;&#160; at org.drools.util.ServiceRegistryImpl.get(ServiceRegistryImpl.java:162)</p><p>&#160;&#160;&#160; at org.drools.concurrent.ExecutorProviderFactory$ExecutorProviderHolder.&lt;clinit&gt;(ExecutorProviderFactory.java:8)</p><p>&#160;&#160;&#160; ... 82 more</p><p>Caused by: java.lang.IllegalArgumentException: Unable to instantiate 'org.drools.concurrent.ExecutorProviderImpl'</p><p>&#160;&#160;&#160; at org.drools.util.ServiceRegistryImpl$ReflectionInstantiator.newInstance(ServiceRegistryImpl.java:213)</p><p>&#160;&#160;&#160; at org.drools.util.ServiceRegistryImpl$ReflectionInstantiator.call(ServiceRegistryImpl.java:205)</p><p>&#160;&#160;&#160; at org.drools.util.ServiceRegistryImpl.get(ServiceRegistryImpl.java:160)</p><p>&#160;&#160;&#160; ... 83 more</p><p>Caused by: java.lang.ClassNotFoundException: org.drools.concurrent.ExecutorProviderImpl</p><p>&#160;&#160;&#160; at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)</p><p>&#160;&#160;&#160; at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)</p><p>&#160;&#160;&#160; at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)</p><p>&#160;&#160;&#160; at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)</p><p>&#160;&#160;&#160; at java.lang.ClassLoader.loadClass(ClassLoader.java:247)</p><p>&#160;&#160;&#160; at java.lang.Class.forName0(Native Method)</p><p>&#160;&#160;&#160; at java.lang.Class.forName(Class.java:169)</p><p>&#160;&#160;&#160; at org.drools.util.ServiceRegistryImpl$ReflectionInstantiator.newInstance(ServiceRegistryImpl.java:210)</p><p>&#160;&#160;&#160; ... 85 more</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/758994#758994">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>