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
13 years, 2 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>
13 years, 2 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
13 years, 2 months
Stateless session dis-associating listeners after first execute call. Bug or a feature?
by Michal Bali
Hello,
I am using a stateless session. First I add an agenda event listener. When
I first call session.execute(Itelable) all works as expected. However when
I call it the second time (without adding the listener again) the listener
does not seem to be called at all.
However note that when I call session.getAgendaEventListeners() the event
listener is always there.
IMHO I am guessing that the 'dispose' method that is called behind the
scenes possibly dis-associates the event listener.
I've tested this with 5.5.Final. BTW This worked fine with Drools 5.0. I
haven't checked later versions.
I wonder is this a bug or a feature?
Isolated test case is attached.
Thank you.
Best regards,
Michal
13 years, 2 months
How to determine Drools runtime version?
by Ansgar Konermann
Hi,
I'd like to determine at runtime which version of Drools is in use/on
the classpath. I cannot use reflection on the Drools classes itself, as
this will not work in the intended runtime environment (Google App Engine).
The following code works in a normal Java VM, but not in GAE:
Package droolsCorePackage = KnowledgePackageImp.class.getPackage();
String implementationTitle = droolsCorePackage.getImplementationTitle();
String implementationVersion =
droolsCorePackage.getImplementationVersion();
In GAE, the getImplementation{Title|Version} methods both return null.
Is there another, maybe more "official" way of determining the Drools
version? I'd like to support Drools 5.x.y starting at x >= 3.
Best regards
Ansgar
13 years, 3 months
error when running guvnor
by kurrent93
Hi
I've just deployed Guvnor 5.5 final into Tomcat 7.
When I go to view guvnor I get this error:
400 Sorry, a technical error occurred. Please contact a system
administrator.
500 The call failed on the server; see server log for details
In the guvnor event log I get:
Service method 'public abstract boolean
org.drools.guvnor.client.rpc.RepositoryService.isDoNotInstallSample()' threw
an unexpected exception: org.jboss.weld.exceptions.WeldException:
WELD-000049 Unable to invoke [method] @PostConstruct public
org.drools.guvnor.server.repository.RepositoryStartupService.create() on
org.drools.guvnor.server.repository.ProductionRepositoryStartupService@2d00c385
WELD-000049 Unable to invoke [method] @PostConstruct public
org.drools.guvnor.server.repository.RepositoryStartupService.create() on
org.drools.guvnor.server.repository.ProductionRepositoryStartupService@2d00c385
I dont see anything relavant in the tomcat logs.
Any idea how to fix this?
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/error-when-running-guvnor-tp4021224.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months
Use of otherwise
by Manasi
Hi,
In my drools application I have following web-guided decision table:
Rule Col1 Col2 Col3
Fields
Rule1 false false abc
field1,field2
Rule2 false true (any value
field2
including "abc")
In Rule 2 above we have condition as:
*If Col1 is false and
If Col2 is true and
If Col3 is having any value including "abc" Then
*
return *field2* in action column.
We have created web-guided decision table in Guvnor and we have included
above 2 rules.
We have tried using <otherwise>, but as per <otherwise> functionality if we
use <otherwise> in Rule2 Col3 ,then it will take all values other than "abc"
and we need to consider "abc" value also.
Please suggest how to solve this scenario?
Thanks,
Manasi.
--
View this message in context: http://drools.46999.n3.nabble.com/Use-of-otherwise-tp4021306.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months