Drools 5.4.0.FINAL and OSGI. Unable to instantiate service for Class 'org.drools.concurrent.ExecutorProvider'
by Per Sterner
Hello,
I have been using Drools 5.3.0.FINAL until now. I am upgrading my
running system with 5.4.0.FINAL. The bundles are all runing. I got some
error messages and tried to reduce the problem and created a simple bundle.
The code only inserts facts and after 20 facts I get the following error:
[ERROR] [System] - Exception in thread "Thread-8"
java.lang.ExceptionInInitializerError
[ERROR] [System] - at
org.drools.concurrent.ExecutorProviderFactory.getExecutorProvider(ExecutorProviderFactory.java:12)
[ERROR] [System] - at
org.drools.rule.constraint.MvelConstraint$ExecutorHolder.<clinit>(MvelConstraint.java:208)
[ERROR] [System] - at
org.drools.rule.constraint.MvelConstraint.jitEvaluator(MvelConstraint.java:199)
[ERROR] [System] - at
org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:164)
[ERROR] [System] - at
org.drools.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:124)
[ERROR] [System] - at
org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:137)
[ERROR] [System] - at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
[ERROR] [System] - at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
[ERROR] [System] - at
org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
[ERROR] [System] - at
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:337)
[ERROR] [System] - at
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:298)
[ERROR] [System] - at
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:123)
[ERROR] [System] - at
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:53)
[ERROR] [System] - at
de.pelle7.drools.test1.simpletest.SimpleTestDrools$1.run(SimpleTestDrools.java:74)
[ERROR] [System] - Caused by: java.lang.IllegalArgumentException: Unable
to instantiate service for Class 'org.drools.concurrent.ExecutorProvider'
[ERROR] [System] - at
org.drools.util.ServiceRegistryImpl.get(ServiceRegistryImpl.java:162)
[ERROR] [System] - at
org.drools.concurrent.ExecutorProviderFactory$ExecutorProviderHolder.<clinit>(ExecutorProviderFactory.java:8)
[ERROR] [System] - ... 14 more
[ERROR] [System] - Caused by: java.lang.IllegalArgumentException: Unable
to instantiate 'org.drools.concurrent.ExecutorProviderImpl'
[ERROR] [System] - at
org.drools.util.ServiceRegistryImpl$ReflectionInstantiator.newInstance(ServiceRegistryImpl.java:213)
[ERROR] [System] - at
org.drools.util.ServiceRegistryImpl$ReflectionInstantiator.call(ServiceRegistryImpl.java:205)
[ERROR] [System] - at
org.drools.util.ServiceRegistryImpl.get(ServiceRegistryImpl.java:160)
[ERROR] [System] - ... 15 more
[ERROR] [System] - Caused by: java.lang.ClassNotFoundException:
org.drools.concurrent.ExecutorProviderImpl
[ERROR] [System] - at
org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
[ERROR] [System] - at
org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
[ERROR] [System] - at
org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
[ERROR] [System] - at
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
[ERROR] [System] - at java.lang.ClassLoader.loadClass(Unknown Source)
[ERROR] [System] - at java.lang.Class.forName0(Native Method)
[ERROR] [System] - at java.lang.Class.forName(Unknown Source)
[ERROR] [System] - at
org.drools.util.ServiceRegistryImpl$ReflectionInstantiator.newInstance(ServiceRegistryImpl.java:210)
[ERROR] [System] - ... 17 more
The Rule file:
package de.pelle7.drools.test1.users.rules.impl;
import de.pelle7.drools.test1.simpletest.*;
import org.jbpm.ruleflow.instance.*;
rule "Funny Rule #1"
dialect "java"
when
$testObject : TestObjectA( value == 0 ) from entry-point "my_entry"
then
System.err.println("New Item: " + $testObject);
retract($testObject);
end
If I change the line
--> $testObject : TestObjectA( value == 0 ) from entry-point "my_entry"
to
--> $testObject : TestObjectA( ) from entry-point "my_entry"
there is no problem.
In the java code i initialize a Drools Session programatically and add
one rule file:
package de.pelle7.drools.test1.simpletest;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseConfiguration;
import org.drools.KnowledgeBaseFactoryService;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderConfiguration;
import org.drools.builder.KnowledgeBuilderFactoryService;
import org.drools.builder.ResourceType;
import org.drools.definition.KnowledgePackage;
import org.drools.io.ResourceFactory;
import org.drools.io.ResourceFactoryService;
import org.drools.runtime.StatefulKnowledgeSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SimpleTestDrools {
public static final String DEFAULT_ENTRY = "my_entry";
private static Logger logger =
LoggerFactory.getLogger(SimpleTestDrools.class);
private StatefulKnowledgeSession droolsSession;
private KnowledgeBuilderFactoryService
droolsKnowledgeBuilderFactoryService;
private ResourceFactoryService droolsResourceFactoryService;
private KnowledgeBaseFactoryService droolsKnowledgeBaseFactoryService;
public static Logger getLogger() {
return logger;
}
public StatefulKnowledgeSession getDroolsSession() {
return droolsSession;
}
public void start() {
KnowledgeBuilder kbuilder =
getDroolsKnowledgeBuilderFactoryService().newKnowledgeBuilder();
KnowledgeBaseConfiguration config =
getDroolsKnowledgeBaseFactoryService().newKnowledgeBaseConfiguration();
//config.setOption( MBeansOption.ENABLED );
KnowledgeBase knowledgeBase =
getDroolsKnowledgeBaseFactoryService().newKnowledgeBase(config);
droolsSession = knowledgeBase.newStatefulKnowledgeSession();
LinkedList<URI> resourcesList = new LinkedList<URI>();
try {
resourcesList.add(
getClass().getResource("MyDrools.drl").toURI() );
addResources(droolsSession,
getDroolsKnowledgeBuilderFactoryService(),
resourcesList);
} catch (Exception e) {
e.printStackTrace();
}
new Thread() {
public void run() {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}
System.out.println("Go 1");
for (int i = 0; i< 1000; i++) {
System.out.println(i);
getDroolsSession().getWorkingMemoryEntryPoint(DEFAULT_ENTRY).insert(new
TestObjectA());
getDroolsSession().fireAllRules();
try {
Thread.sleep(1);
} catch (InterruptedException e) {
}
}
System.out.println("Go 2");
};
}.start();
System.err.println("wait");
//getDroolsSession().fireUntilHalt();
}
public static void addResources(
StatefulKnowledgeSession droolsSession,
KnowledgeBuilderFactoryService
droolsKnowledgeBuilderFactoryService,
List<URI> resources
) throws MyDroolsException {
getLogger().debug("Drools: Register: " + resources);
MyDroolsException exception = null;
KnowledgeBuilderConfiguration lnowledgeBuilderConfiguration =
droolsKnowledgeBuilderFactoryService.newKnowledgeBuilderConfiguration();
HashSet<URI> defects = new HashSet<URI>();
KnowledgeBuilder kbuilder = null;
while (true) {
URI uriError = null;
kbuilder =
droolsKnowledgeBuilderFactoryService.newKnowledgeBuilder(lnowledgeBuilderConfiguration);
try {
Iterator<URI> it = resources.iterator();
while (it.hasNext()) {
URI uri = (URI) it.next();
if (defects.contains(uri)) {
continue;
}
StringBuilder builder = new StringBuilder();
builder.append("Adding drools file '" +
uri.toString() + "'");
URL url = uri.toURL();
InputStream iStream = url.openStream();
ResourceType resourceType;
String path = uri.getPath().toLowerCase();
resourceType =
ResourceType.determineResourceType(path);
getLogger().debug(builder.toString());
kbuilder.add(ResourceFactory.newInputStreamResource(iStream), resourceType);
// Check the builder for errors
if (kbuilder.hasErrors()) {
uriError = uri;
//getLogger().error(kbuilder.getErrors().toString());
String errorMessage =
kbuilder.getErrors().toString();
kbuilder.getErrors().clear();
throw new MyDroolsException(errorMessage);
}
try {
iStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (Throwable e) {
if (uriError != null) {
defects.add(uriError);
}
String msg = "Error in Resource '" + uriError + "'";
getLogger().error(msg);
e.printStackTrace();
if (exception != null) {
exception = new MyDroolsException(msg, exception);
} else {
exception = new MyDroolsException(msg);
}
exception = new MyDroolsException(e.getMessage(),
exception);
continue;
}
// All done!
break;
}
final Collection<KnowledgePackage> pkgs =
kbuilder.getKnowledgePackages();
droolsSession.getKnowledgeBase().addKnowledgePackages(pkgs);
if (exception != null) {
throw new MyDroolsException("Error while adding
resources!", exception);
}
}
public KnowledgeBuilderFactoryService
getDroolsKnowledgeBuilderFactoryService() {
return droolsKnowledgeBuilderFactoryService;
}
public void setDroolsKnowledgeBuilderFactoryService(
KnowledgeBuilderFactoryService
droolsKnowledgeBuilderFactoryService) {
this.droolsKnowledgeBuilderFactoryService =
droolsKnowledgeBuilderFactoryService;
}
public ResourceFactoryService getDroolsResourceFactoryService() {
return droolsResourceFactoryService;
}
public void setDroolsResourceFactoryService(
ResourceFactoryService droolsResourceFactoryService) {
this.droolsResourceFactoryService = droolsResourceFactoryService;
}
public KnowledgeBaseFactoryService
getDroolsKnowledgeBaseFactoryService() {
return droolsKnowledgeBaseFactoryService;
}
public void setDroolsKnowledgeBaseFactoryService(
KnowledgeBaseFactoryService
droolsKnowledgeBaseFactoryService) {
this.droolsKnowledgeBaseFactoryService =
droolsKnowledgeBaseFactoryService;
}
}
Some of the bundles in my runtime are:
39 ACTIVE org.drools.core_5.4.0.Final
66 ACTIVE org.drools.compiler_5.4.0.Final
78 ACTIVE org.drools.templates_5.4.0.Final
94 ACTIVE org.drools.internalapi_5.4.0.Final
136 ACTIVE org.drools.decisiontables_5.4.0.Final
189 ACTIVE org.drools.api_5.4.0.Final
191 ACTIVE org.mvel2_2.1.0.drools16
6 ACTIVE org.jbpm.flow.core_5.3.0.Final
13 ACTIVE org.jbpm.bpmn2_5.3.0.Final
71 ACTIVE org.jbpm.flow.builder_5.3.0.Final
142 ACTIVE org.jbpm.flow-persistence-jpa_5.3.0.FINAL
regards,
Per Sterner
12 years, 11 months
Change Scanner does not start
by Antonio Anderson Souza
Dear All,
I have an application that use Guvnor 5.4.0 final as the rules repository
and a DroolsServer 5.4.0 final (with Spring Camel) to provide rule engine
via a Rest Webservices, all of those apps Running in a JBossAS 7.1.
All of the service are working perfectly, except the
resource-change-scanner that is configured in the knowledge-services.xml
[1] as it's described in the documentation.
When Drools-Server are deployed the Change Scanner does not start (I'm
monitoring the change scanner via Wireshark analyzing the communication
between DroolServer and Guvnor), I've created an small JSP file [2] that
invoke the ChangeScanner start method, when i run the JSP the Change
Scanner start to work (i can see the http requests from Drools Server do
Guvnor to see if the knowledge base had changed), but after Change Scanner
started working the rules are not triggered anymore.
So without Change Scanner I've all of the knowledge service running
properly, but the App is unable to detect rules changes, when I explicitly
(via JSP) start the Change Scanner all of the knowledge service stopped
working.
Change Scanner starts automatically?
Does anybody has some idea to help me?
[1] ------------------------------------------------------------------------
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:drools="http://drools.org/schema/drools-spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://drools.org/schema/drools-spring
http://drools.org/schema/drools-spring-1.3.0.xsd">
<drools:grid-node id="node1"/>
<drools:resource-change-scanner id="scanner" interval="10" />
<drools:kbase id="kbase1" node="node1" />
<drools:kagent id="kagent1" kbase="kbase1">
<drools:resources>
<drools:resource type="CHANGE_SET" source="classpath:ChangeSet.xml" />
</drools:resources>
</drools:kagent>
<drools:ksession id="ksession1" type="stateless" kbase="kbase1"
node="node1"/>
</beans>
[2] ------------------------------------------------------------------------
<%@ page language="java" contentType="text/html; charset=utf-8" %>
<%
org.drools.io.ResourceChangeScannerConfiguration sconf =
org.drools.io.ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
sconf.setProperty("drools.resource.scanner.interval", "5");
org.drools.io.ResourceFactory.getResourceChangeScannerService().configure(sconf);
org.drools.io.ResourceFactory.getResourceChangeScannerService().start();
org.drools.io.ResourceFactory.getResourceChangeNotifierService().start();
%>
Best Regards,
Antonio Anderson Souza
<http://174.129.217.139:8080/makecallclient/callme?p=YXNvdXphQHZvaWNlLmJyY...>
Blog <http://www.antonioams.com> - Twitter <http://twitter.com/antonioams>-
LinkedIn <http://br.linkedin.com/in/antonioams> -
Facebook<http://www.facebook.com/antonioams>
12 years, 11 months
Drools: Using Declared Types in Decision Tables
by David Smith
Hi,
I am trying to use a declared type in a decision table
but get an "Unable to resolve ObjectType" message.
The declared type is in a file types.drl,
I have a spreadsheet test.xls that has a Ruleset with
an import line for the declared type.
Is it possible to reference a declared type from a decision table?
Is it possible to declare a type in a decision table?
Thanks
David
12 years, 12 months
Drools 5.4 Jitting Error
by gboro54
I just updated to Drools 5.4 and I am not getting the following error on all
my map accessors:
10:41:12,997 ERROR [stderr] (Thread-169) Exception in thread "Thread-169"
java.lang.RuntimeException: Exception jitting: feeKeys[1] == null
10:41:12,998 ERROR [stderr] (Thread-169) at
org.drools.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:219)
10:41:12,999 ERROR [stderr] (Thread-169) at
org.drools.rule.constraint.MvelConstraint.access$000(MvelConstraint.java:41)
10:41:13,000 ERROR [stderr] (Thread-169) at
org.drools.rule.constraint.MvelConstraint$1.run(MvelConstraint.java:201)
10:41:13,000 ERROR [stderr] (Thread-169) at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
10:41:13,001 ERROR [stderr] (Thread-169) at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
10:41:13,002 ERROR [stderr] (Thread-169) at
java.lang.Thread.run(Thread.java:662)
10:41:13,002 ERROR [stderr] (Thread-169) Caused by: java.lang.VerifyError:
(class: ConditionEvaluator51817e9f4a7542c5b295be7d674f854c, method: evaluate
signature:
(Ljava/lang/Object;Lorg/drools/common/InternalWorkingMemory;Lorg/drools/reteoo/LeftTuple;)Z)
Expecting to find object/array on stack
10:41:13,004 ERROR [stderr] (Thread-169) at
java.lang.Class.getDeclaredConstructors0(Native Method)
10:41:13,004 ERROR [stderr] (Thread-169) at
java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
10:41:13,005 ERROR [stderr] (Thread-169) at
java.lang.Class.getConstructor0(Class.java:2699)
10:41:13,005 ERROR [stderr] (Thread-169) at
java.lang.Class.getConstructor(Class.java:1657)
10:41:13,006 ERROR [stderr] (Thread-169) at
org.drools.rule.builder.dialect.asm.ClassGenerator.newInstance(ClassGenerator.java:173)
10:41:13,006 ERROR [stderr] (Thread-169) at
org.drools.rule.constraint.ASMConditionEvaluatorJitter.jitEvaluator(ASMConditionEvaluatorJitter.java:53)
10:41:13,007 ERROR [stderr] (Thread-169) at
org.drools.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:217)
10:41:13,008 ERROR [stderr] (Thread-169) ... 5 more
Could anyone indicate how to fix this?
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-5-4-Jitting-Error-tp3999176.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years
Rules with variable timers
by Shannon Hastings
Is there a way to write a rule in DRL that uses a timer or something that is dynamic. I.E. I want the time that rule waits to fire to be dependent on a variable such as below:
rule "CheckDoseMissed"
no-loop
timer(int: $eventA.sleepTime)
when
$eventA : MyEvent()
………..
----------
Shannon Hastings
Inventrio
shannon.hastings(a)inventrio.com
(614) 389-2795 ext: 101
http://www.inventrio.com
13 years
Building our own UI for Drools
by kapokfly
Due to some reasons (for example, build a consistent UI within our own
application, easier to work with our own meta data, don't want SSO etc), we
are considering to build our own UI to generate Drools rule file basing on
the user input via the UI , has anyone tried this before? Is there any
library shipped within Drools Gunvor can be used to be easier to work with
Drools rule syntax?
Thanks,
Ivan
-----
Ivan, your Panda, forever
--
View this message in context: http://drools.46999.n3.nabble.com/Building-our-own-UI-for-Drools-tp350884...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 1 month
Drools Guvnor API information?
by Vikas Hazrati
Hi,
I am looking at using Guvnor for our project where users would be creating
rules using our UI. For this i need to add / modify rule or any asset for
that matter using an api.
Unfortunately, i could not find enough documentation to suggest the best way
to use the REST api, which I guess is provided by Guvnor. Could someone let
me know the location of where i can get some information for this api. I
also see that the issue GUVNOR-1080
(https://issues.jboss.org/browse/GUVNOR-1080) is marked resolved so the api
should exist right? or that we cannot access it remotely until we have the
Atom Pub Interface done?
Help appreciated .
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Guvnor-API-inf...
Sent from the Drools - User mailing list archive at Nabble.com.
13 years, 2 months