0 Replies Latest reply on Sep 11, 2012 8:44 AM by Tomasz Kleszczyński

    Instantiation of org.drools.concurrent.ExecutorProviderImpl in OSGi - solution proposal

    Tomasz Kleszczyński Newbie

      Hello everybody,

       

      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 http://lists.jboss.org/pipermail/rules-users/2012-May/026839.html but in that thread there was not correct solution

       

      During invocation on OSGi environment I've got following problem:

      1. org.drools.concurrent.ExecutorProviderFactory$ExecutorProviderHolder tries to obtain instance of class org.drools.concurrent.ExecutorProvider using org.drools.util.ServiceRegistryImpl.get method
      2. org.drools.util.ServiceRegistryImpl doesn't have any implementation of org.drools.concurrent.ExecutorProvider in it's registry
      3. 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.
      4. 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.

       

      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.

       

      Stacktrace I've got in this situation.

      SEVERE: Unable to start blueprint container for bundle jbpm5-example-client

      org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to intialize bean sampleProcessClient

          at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:710)

          at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:820)

          at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:783)

          at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)

          at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

          at java.util.concurrent.FutureTask.run(FutureTask.java:138)

          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:648)

          at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:340)

          at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:242)

          at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)

          at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)

          at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

          at java.util.concurrent.FutureTask.run(FutureTask.java:138)

          at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)

          at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)

          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

          at java.lang.Thread.run(Thread.java:662)

      Caused by: java.lang.ExceptionInInitializerError

          at org.drools.concurrent.ExecutorProviderFactory.getExecutorProvider(ExecutorProviderFactory.java:12)

          at org.drools.rule.constraint.MvelConstraint$ExecutorHolder.<clinit>(MvelConstraint.java:208)

          at org.drools.rule.constraint.MvelConstraint.jitEvaluator(MvelConstraint.java:199)

          at org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:164)

          at org.drools.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:124)

          at org.drools.reteoo.AlphaNode.modifyObject(AlphaNode.java:154)

          at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateModifyObject(CompositeObjectSinkAdapter.java:507)

          at org.drools.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(CompositeObjectSinkAdapter.java:432)

          at org.drools.reteoo.ObjectTypeNode.modifyObject(ObjectTypeNode.java:314)

          at org.drools.reteoo.EntryPointNode.modifyObject(EntryPointNode.java:265)

          at org.drools.common.NamedEntryPoint.update(NamedEntryPoint.java:470)

          at org.drools.common.NamedEntryPoint.update(NamedEntryPoint.java:370)

          at org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:317)

          at org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:312)

          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)

          at org.foo.jbpm5.drools.rules.pricing.Rule_Pricing_based_on_demand____Used_AUDI_70__of_the_original_price_77e52c0333d54b068cd3bc5e98c79344DefaultConsequenceInvokerGenerated.evaluate(Unknown Source)

          at org.foo.jbpm5.drools.rules.pricing.Rule_Pricing_based_on_demand____Used_AUDI_70__of_the_original_price_77e52c0333d54b068cd3bc5e98c79344DefaultConsequenceInvoker.evaluate(Unknown Source)

          at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1273)

          at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1209)

          at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1442)

          at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)

          at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)

          at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)

          at org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:295)

          at org.foo.jbpm5.drools.DefineCarPriceWorkItemHandler.executeWorkItem(DefineCarPriceWorkItemHandler.java:24)

          at org.drools.process.instance.impl.DefaultWorkItemManager.internalExecuteWorkItem(DefaultWorkItemManager.java:70)

          at org.jbpm.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:105)

          at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:124)

          at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerNodeInstance(NodeInstanceImpl.java:205)

          at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:164)

          at org.jbpm.workflow.instance.impl.ExtendedNodeInstanceImpl.triggerCompleted(ExtendedNodeInstanceImpl.java:47)

          at org.jbpm.workflow.instance.node.StateBasedNodeInstance.triggerCompleted(StateBasedNodeInstance.java:162)

          at org.jbpm.workflow.instance.node.StateBasedNodeInstance.triggerCompleted(StateBasedNodeInstance.java:143)

          at org.jbpm.workflow.instance.node.WorkItemNodeInstance.triggerCompleted(WorkItemNodeInstance.java:239)

          at org.jbpm.workflow.instance.node.WorkItemNodeInstance.workItemCompleted(WorkItemNodeInstance.java:301)

          at org.jbpm.workflow.instance.node.WorkItemNodeInstance.signalEvent(WorkItemNodeInstance.java:277)

          at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.signalEvent(WorkflowProcessInstanceImpl.java:326)

          at org.drools.process.instance.impl.DefaultWorkItemManager.completeWorkItem(DefaultWorkItemManager.java:116)

          at org.foo.jbpm5.drools.RankCarWorkItemHandler.executeWorkItem(RankCarWorkItemHandler.java:27)

          at org.drools.process.instance.impl.DefaultWorkItemManager.internalExecuteWorkItem(DefaultWorkItemManager.java:70)

          at org.jbpm.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:105)

          at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:124)

          at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerNodeInstance(NodeInstanceImpl.java:205)

          at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:164)

          at org.jbpm.workflow.instance.node.StartNodeInstance.triggerCompleted(StartNodeInstance.java:49)

          at org.jbpm.workflow.instance.node.StartNodeInstance.internalTrigger(StartNodeInstance.java:41)

          at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:124)

          at org.jbpm.ruleflow.instance.RuleFlowProcessInstance.internalStart(RuleFlowProcessInstance.java:35)

          at org.jbpm.process.instance.impl.ProcessInstanceImpl.start(ProcessInstanceImpl.java:188)

          at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.start(WorkflowProcessInstanceImpl.java:303)

          at org.jbpm.process.instance.ProcessRuntimeImpl.startProcessInstance(ProcessRuntimeImpl.java:168)

          at org.drools.common.AbstractWorkingMemory.startProcessInstance(AbstractWorkingMemory.java:1092)

          at org.drools.impl.StatefulKnowledgeSessionImpl.startProcessInstance(StatefulKnowledgeSessionImpl.java:330)

          at org.foo.jbpm5.example.client.SampleProcessClient.startStatelessDroolsEvaluation(SampleProcessClient.java:59)

          at org.foo.jbpm5.example.client.SampleProcessClient.init(SampleProcessClient.java:48)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:238)

          at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:954)

          at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:708)

          ... 20 more

      Caused by: java.lang.IllegalArgumentException: Unable to instantiate service for Class 'org.drools.concurrent.ExecutorProvider'

          at org.drools.util.ServiceRegistryImpl.get(ServiceRegistryImpl.java:162)

          at org.drools.concurrent.ExecutorProviderFactory$ExecutorProviderHolder.<clinit>(ExecutorProviderFactory.java:8)

          ... 82 more

      Caused by: java.lang.IllegalArgumentException: Unable to instantiate 'org.drools.concurrent.ExecutorProviderImpl'

          at org.drools.util.ServiceRegistryImpl$ReflectionInstantiator.newInstance(ServiceRegistryImpl.java:213)

          at org.drools.util.ServiceRegistryImpl$ReflectionInstantiator.call(ServiceRegistryImpl.java:205)

          at org.drools.util.ServiceRegistryImpl.get(ServiceRegistryImpl.java:160)

          ... 83 more

      Caused by: java.lang.ClassNotFoundException: org.drools.concurrent.ExecutorProviderImpl

          at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)

          at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)

          at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)

          at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)

          at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

          at java.lang.Class.forName0(Native Method)

          at java.lang.Class.forName(Class.java:169)

          at org.drools.util.ServiceRegistryImpl$ReflectionInstantiator.newInstance(ServiceRegistryImpl.java:210)

          ... 85 more