KnowledgeAgent and OSGI
by mmarmol
Hi, I have managed to install Drools-core and Drools-compiler in my Equinox
osgi environment, I can compile rules and execute them just fine, I was just
wandering how to configure a KnowledgeAgent using
KnowledgeBuilderFactoryService and KnowledgeBaseFactoryService. I managed to
configure one but i am not able to reload rules when they change at runtime.
I have started ResourceChangeScannerService and
ResourceChangeNotifierService, changeset related to the rules file gets read
but no change gets implemented. An idea?
Here is the code:
ResourceFactory.getResourceChangeScannerService().start();
ResourceFactory.getResourceChangeNotifierService().start();
ServiceReference serviceRef = bc
.getServiceReference(ServiceRegistry.class.getName());
ServiceRegistry registry = (ServiceRegistry) bc.getService(serviceRef);
KnowledgeBuilderFactoryService knowledgeBuilderFactoryService = registry
.get(KnowledgeBuilderFactoryService.class);
KnowledgeBaseFactoryService knowledgeBaseFactoryService = registry
.get(KnowledgeBaseFactoryService.class);
ResourceFactoryService resourceFactoryService = registry
.get(ResourceFactoryService.class);
KnowledgeBuilderConfiguration kbConf = knowledgeBuilderFactoryService
.newKnowledgeBuilderConfiguration(null, getClass()
.getClassLoader());
KnowledgeBuilder kbuilder = knowledgeBuilderFactoryService
.newKnowledgeBuilder(kbConf);
ResourceFactoryService resource = resourceFactoryService;
kbuilder.add(resource.newFileSystemResource(filePath),
ResourceType.CHANGE_SET);
if (kbuilder.hasErrors()) {
System.out.println(kbuilder.getErrors());
throw new RuntimeException(kbuilder.getErrors().toString());
}
KnowledgeBaseConfiguration kbaseConf = knowledgeBaseFactoryService
.newKnowledgeBaseConfiguration(null, getClass()
.getClassLoader());
KnowledgeBase kbase = knowledgeBaseFactoryService
.newKnowledgeBase(kbaseConf);
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
KnowledgeAgentConfiguration aconf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
aconf.setProperty("drools.agent.scanDirectories", "true");
aconf.setProperty("drools.agent.scanResources", "true");
aconf.setProperty("drools.agent.newInstance", "false");
kagent = KnowledgeAgentFactory.newKnowledgeAgent( "CoreDroolsAgent",kbase,
aconf);
kagent.applyChangeSet(resource.newFileSystemResource(filePath));
Thanks in advance!
Cheers
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/KnowledgeAgent-and-OS...
Sent from the Drools - User mailing list archive at Nabble.com.
13 years, 8 months
Updating to 5.1 - what jars do I need to replace?
by Stephen Mcgruer
Hi guys,
Really struggling with what jars I need to replace to update to Drools
5.1. I've tried replacing just the "drools" jars, but I get a
"java.io.InvalidClassException:
org.drools.rule.DialectRuntimeRegistry; local class incompatible:
stream classdesc serialVersionUID = 5308493362083281112, local class
serialVersionUID = 510" error, so I assume I need to replace more -
but I don't know which. I tried replacing all of the ones that had new
versions in the drools 5.1 binaries, but this caused Hibernate to fail
on runtime, claiming it couldnt understand annotations! The following
is a list of the jars currently in the project for Drools 5.0 - I did
not put together this list originally, so some might not be needed but
I dont know which. I would much appreciate some help working out which
jars I need to change to get my code to talk to Guvnor 5.1...
Main lib:
activation-1.1.jar
antlr-2.7.6.jar
antlrworks-1.3.1.jar
btm-1.3.2.jar
com.springsource.org.apache.commons.pool-1.5.3.jar
commons-collections-3.1.jar
commons-dbcp-1.4.jar
commons-io-1.3.2.jar
commons-lang-2.4.jar
commons-logging.jar
core-3.4.2.v_883_R34x.jar
dom4j.jar
drools-ant-5.0.1.jar
drools-api-5.0.1.jar
drools-compiler-5.0.1.jar
drools-core-5.0.1.jar
drools-decisiontables-5.0.1.jar
drools-persistence-jpa-5.0.1.jar
drools-process-task-5.0.1.jar
drools-solver-core-5.0.1.jar
drools-templates-5.0.1.jar
drools-verifier-5.0.1.jar
drools-workitems-5.0.1.jar
ejb3-persistence.jar
hibernate-annotations.jar
hibernate-commons-annotations.jar
hibernate-core.jar
hibernate-entitymanager-3.3.2.GA.jar
hibernate3.jar
janino-2.5.15.jar
jars.txt
javassist-3.9.0.GA.jar
joda-time-1.6.jar
jstl.jar
jta-1.1.jar
junit-3.8.1.jar
log4j-1.2.15.jar
mail-1.4.jar
mvel2-2.0.10.jar
mysql-connector-java-5.1.12-bin.jar
persistence-api-1.0.jar
servlet-api-2.3.jar
slf4j-api-1.5.6.jar
slf4j-log4j12-1.5.10.jar
spring-2.5.6.jar
spring-beans-2.5.6.jar
spring-context-2.5.6.jar
spring-context-support-2.5.6.jar
spring-core-2.5.6.jar
spring-test-2.5.6.jar
spring-web-2.5.6.jar
spring-webmvc.jar
spring.jar
standard.jar
xpp3_min-1.1.4c.jar
xstream-1.3.1.jar
WEBINF:
antlr-2.7.6.jar
antlrworks-1.3.1.jar
com.springsource.org.apache.commons.pool-1.5.3.jar
commons-collections-3.1.jar
commons-dbcp-1.4.jar
commons-lang-2.4.jar
commons-logging.jar
dom4j.jar
drools-ant-5.0.1.jar
drools-api-5.0.1.jar
drools-compiler-5.0.1.jar
drools-core-5.0.1.jar
drools-decisiontables-5.0.1.jar
drools-persistence-jpa-5.0.1.jar
drools-process-task-5.0.1.jar
drools-templates-5.0.1.jar
drools-verifier-5.0.1.jar
drools-workitems-5.0.1.jar
ejb3-persistence.jar
hibernate-annotations.jar
hibernate-commons-annotations.jar
hibernate-core.jar
hibernate3.jar
javassist-3.9.0.GA.jar
jstl.jar
jta-1.1.jar
log4j-1.2.15.jar
mvel2-2.0.10.jar
mysql-connector-java-5.1.12-bin.jar
slf4j-api-1.5.6.jar
slf4j-log4j12-1.5.10.jar
spring-webmvc.jar
spring.jar
standard.jar
test.txt
xstream-1.3.1.jar
Cheers,
Stephen
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
13 years, 8 months
Help : Enabling Role Base Authorization in Guvnor
by Han Ming Low
Hi all,
I try to enable the Role Base Authorization in Guvnor after it was running
fine with the default login mechanism.
But, encountered some problem with the attempt.
What I did was that in the components.xml,
- commented out the default <security:identity
authenticate-method="#{defaultAuthenticator.authenticate}"/>
- uncomment the <security:identity
authenticate-method="#{authenticator.authenticate}"
jaas-config-name="other"/>
- change the role base authorization to true,
<security:role-based-permission-resolver
enable-role-based-authorization="true"/>
And at the login-config.xml
I have changed the "other" application policy to
<application-policy name = "other">
<authentication>
<login-module code =
"org.jboss.security.auth.spi.UsersRolesLoginModule"
flag = "required" >
<module-option
name="usersProperties">props/guvnor-users.properties</module-option>
<module-option
name="rolesProperties">props/guvnor-roles.properties</module-option>
</login-module>
</authentication>
</application-policy>
guvnor-users.properties
admin=admin12
krisv=krisv
john=john
mary=mary
guvnor-roles.properties
admin=admin
krisv=admin,manager,user
john=admin,manager,user
mary=admin,manager,user
After restarting JBoss, I can login based on the user and password defined
in the guvnor-users.properties.
And, by changing the password in the properties, I verified that it is
taking in the value from the file itself.
However, when I login as user admin and tried to access the Administration |
User Permission or Event Log,
I'm prompt "Sorry, insufficient permissions to perform this action."
The error from the console is
11:15:36,046 INFO [STDOUT] ERROR 29-07 11:15:36,046
(LoggingHelper.java:error:76)
Service method 'public abstract java.util.Map
org.drools.guvnor.client.rpc.RepositoryService.listUserPermissions()
throws org.drools.guvnor.client.rpc.DetailedSerializationException'
threw an unexpected exception:
org.jboss.seam.security.AuthorizationException:
Authorization check failed for
permission[org.drools.guvnor.server.security.AdminType@bf7a4d,admin]
org.jboss.seam.security.AuthorizationException: Authorization check failed
for permission[org.drools.guvnor.server.security.AdminType@bf7a4d,admin]
at
org.jboss.seam.security.Identity.checkPermission(Identity.java:581)
at
org.drools.guvnor.server.ServiceImplementation.listUserPermissions(ServiceImplementation.java:2604)
.....
Checking on the org.drools.guvnor.server.security.RoleTypes code, the
available role should be
admin
analyst
analyst.readonly
package.admin
package.developer
package.readonly
Can anyone help to let me know what's wrong with my configuration?
Thanks.
Han Ming
13 years, 9 months
Guvnor BRL format
by Sreenath Putta
Hi,
I have couples of questions regarding Guvnor BRL format:
We have a requirement to store the rules in XML format, for that we are
planning to use Guvnor Brl format.Right now Guvnor BRL format does not
support for defining Event correlation part (Temporal reasoning part). we
would end up something like putting these event correlation part in a
freeform.
First thing is will there be any support for event correlation in Guvnor in
near future?
If not we are willing to contribute for that effort. we just wanted to find
out what exactly is the process for going forward and defining these
elements?
Thanks,
Sreenath
13 years, 9 months
Failed to read schema document when trying to transform from XML to DRL
by Chang Liu
Hi there,
Error message:
(null: 5, 77): schema_reference.4: Failed to read schema document 'drools.org/drools-5.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
I ran into this issue when experimenting a project that transforming the rules back and forth from DRL to XML with utility classes as documented in following link:
http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/ht...
My code:
...
XmlPackageReader xmlReader = new XmlPackageReader(null);
StringReader sr = new StringReader(rulesInXml);
try {
PackageDescr packageDescr = xmlReader.read(sr);
DrlDumper drlDumper = new DrlDumper();
String drlString = drlDumper.dump(packageDescr);
}
catch (Exception ex) {
System.out.println(ex);
}
...
where string "rulesInXml" is the result xml string transformed from a valid .drl file. It looks like:
<?xml version="1.0" encoding="UTF-8"?>
<package name="com.sample"
xmlns="http://drools.org/drools-5.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0 drools.org/drools-5.0.xsd">
<import name="com.sample.DroolsTest.Message" />
<rule name="Hello World">
<lhs><pattern identifier="m" object-type="Message" >
<field-constraint field-name="status">
<qualified-identifier-restriction evaluator="==">Message.HELLO </qualified-identifier-restriction>
</field-constraint>
<field-binding field-name="message" identifier="myMessage" />
</pattern>
</lhs>
<rhs> System.out.println( myMessage );
m.setMessage( "Goodbye cruel world" );
m.setStatus( Message.GOODBYE );
update( m );
</rhs>
</rule>
<rule name="GoodBye">
<lhs><pattern object-type="Message" >
<field-constraint field-name="status">
<qualified-identifier-restriction evaluator="==">Message.GOODBYE </qualified-identifier-restriction>
</field-constraint>
<field-binding field-name="message" identifier="myMessage" />
</pattern>
</lhs>
<rhs> System.out.println( myMessage );
</rhs>
</rule>
</package>
What did I miss here?
Moreover, the Drools 5.0 API's for XML support are poorly-documented. For example, the constructors of class "XmlPackageReader" has an arg of "SemanticModules" type which is not documented. :(
Any help would be highly appreciated!
Thanks,
Chang
**********************************************************************
CONFIDENTIALITY NOTICE: The information contained in this email is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If you are not the intended recipient, you are hereby notified that any unauthorized review, use, dissemination, distribution or copying of this communication is prohibited and may be subject to legal restriction or sanction. If you have received this email in error, please notify the sender immediately to arrange for return or destruction of the information and all copies. If you are the intended recipient but do not wish to receive communications through this medium, please advise the sender immediately. Thank you
13 years, 9 months
are for loops possible in drools
by ceemh3
does anybody know if there is a way to do for loops in drools ?.
I am trying to loop through a list of string to see if one of the strings
matches a pattern e.g.
def listOfStrings = ['a','a.b','a.b.c']
for(String s:listOfStrings){
if(s matches "^a.b.*$"){
return true
}
}
I have written the following rule based on what documentation I could find,
but I dont think the syntax is correct
rule "Matcher"
when
TestClass : TestClass(($s matches "^a.b.*$") from listOfStrings,
count($s))
then
TestClass.setResponse( "Condition is True !!" );
end
I am finding it hard to find good documentation on the drl language
I would appreciate any help that anybody can give me
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/are-for-loops-possibl...
Sent from the Drools - User mailing list archive at Nabble.com.
13 years, 9 months
Drools Objects not released from heap
by dmiller44
Hello,
I have a weird issue, and I'm trying to figure out if this is a bug I should
report, or an error in my rule. I'm running an application with a heap
space (min: 512mb, max: 1024mb) that gets full and eventually overflows
relatively quickly (12hrs or less). We insert about 112 records into a
Stateful Drools Session (Drools 5.1 CR1 released 7/22/2010) every 30seconds,
using CLOUD session type, single thread, with fireUntilHalt.
Our rules evaluate the object (A) we give it, and in some cases instantiate
a new object (B) and insert it into the session. After processing object
(A), we retract it from the session.
Another rule matches on object (B), and when finished, also retracts the
object.
When I do a heap snapshot, I've noticed quite a few Drools-related classes,
along with unreleased instantiations of object(A) & object(B) (more of the
latter). Obviously I have to take into consideration that objects are being
inserted at the time of the snapshot, but over a couple hours I'll have
1000's of these objects. I've found the only fix to be to release the
session.
I should note - calling session.getObjects() shows an empty list (size 0).
Is this a bug? When retract is called, shouldn't it free up the FactHandle &
Object to be collected? And is instantiating an object in a rule incorrect
for some reason?
Below is a small chart of classes - the number of instances - and space
taken. (TemperatureEvent represents object (A), while AssetShallowRemote
represents object (B)) Any input would be appreciated.
Dan
| Class | Instances |
Size | |
|--------------------------------------------------------------+-----------+----------+---|
| java.lang.String | 1155258 |
41589288 | |
| char[] | 1153540 |
91560120 | |
| java.util.concurrent.LinkedBlockingQueue$Node | 329989 |
10559648 | |
| java.util.LinkedHashMap$Entry | 153489 |
9209340 | |
| java.util.HashMap$Entry | 151929 |
6684876 | |
| java.sql.Timestamp | 117017 |
4212612 | |
| org.drools.reteoo.LeftTuple | 53395 |
8756780 | |
| org.drools.common.AgendaItem | 53390 |
5819510 | |
| org.drools.retoo.RightTuple | 53386 |
5125056 | |
| my.test.package.AssetShallowRemote | 42995 | 11780630 | |
| org.drools.common.DefaultFactHandle | 37273 |
3280024 | |
| org.drools.core.util.ObjectHashSet$ObjectEntry | 37273 |
1341828 | |
| org.drools.common.PropagationContextImpl | 32721 |
2683512 | |
| org.drools.core.util.ObjectHashMap$ObjectEntry | 32721 |
1639924 | |
| my.test.package.TemperatureEvent | 7165 |
917120 | |
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Objects-not-re...
Sent from the Drools - User mailing list archive at Nabble.com.
13 years, 9 months