Hi all,
I'm having problem getting the KnowledgeAgent and Guvnor working
correctly...
On the console I got this reports:
12:35:05,265 INFO [STDOUT] [2009:01:13 12:01:265:info]
ResourceChangeScanner created with default interval=60
12:35:05,265 INFO [STDOUT] [2009:01:13 12:01:265:info]
ResourceChangeScanner reconfigured with interval=30
12:35:06,468 INFO [STDOUT] [2009:01:13 12:01:468:info]
ResourceChangeNotification created
12:35:06,468 INFO [STDOUT] [2009:01:13 12:01:468:debug]
ResourceChangeNotification monitor added
monitor=org.drools.io.impl.ResourceChangeScannerImpl@241eaf
12:35:06,468 INFO [STDOUT] [2009:01:13 12:01:468:debug] KnowledgeAgent
building resource map
12:35:06,468 INFO [STDOUT] [2009:01:13 12:01:468:info] KnowledegAgent has
started listening for ChangeSet notifications
12:35:06,468 INFO [STDOUT] [2009:01:13 12:01:468:info] KnowledgAgent
created, with configuration:
monitorChangeSetEvents=true scanResources=true scanDirectories=true
12:35:06,500 INFO [STDOUT] (null: 3, 88): schema_reference.4: Failed to
read schema document 'drools-change-set-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>.
12:35:06,500 INFO [STDOUT] (null: 3, 88): cvc-elt.1: Cannot find the
declaration of element 'change-set'.
12:35:06,500 INFO [STDOUT] (null: 4, 7): schema_reference.4: Failed to read
schema document 'drools-change-set-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>.
12:35:06,500 INFO [STDOUT] (null: 7, 17): schema_reference.4: Failed to
read schema document 'drools-change-set-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>.
12:35:06,500 INFO [STDOUT] [2009:01:13 12:01:500:info] KnowledgAgent
applying ChangeSet
12:35:06,500 INFO [STDOUT] [2009:01:13 12:01:500:debug] KnowledgeAgent
subscribing to resource=[UrlResource
path='http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/regulation/regulation']
12:35:06,500 INFO [STDOUT] [2009:01:13 12:01:500:debug]
ResourceChangeNotification subscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@1ca7c02 to
resource=[UrlResource
path='http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/regulation/regulation']
12:35:06,500 INFO [STDOUT] [2009:01:13 12:01:500:debug]
ResourceChangeScanner subcribing
notifier=org.drools.io.impl.ResourceChangeNotifierImpl@939c8a to
resource=[UrlResource
path='http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/regulation/regulation']
12:35:06,500 INFO [STDOUT] [2009:01:13 12:01:500:debug] KnowledgeAgent
ChangeSet requires KnowledgeBuilder
12:35:06,500 INFO [STDOUT] [2009:01:13 12:01:500:debug] KnowledgeAgent
rebuilding KnowledgeBase using ChangeSet
12:35:06,500 INFO [STDOUT] PackageName: regulation
12:35:06,500 INFO [STDOUT] PackageVersion: regulation
12:35:06,500 INFO [STDOUT] PackageIsLatest: false
12:35:06,500 INFO [STDOUT] PackageIsSource: false
12:35:06,515 INFO [STDOUT] PackageName: regulation
12:35:06,515 INFO [STDOUT] PackageVersion: regulation
12:35:06,515 INFO [STDOUT] PackageIsLatest: false
12:35:06,515 INFO [STDOUT] PackageIsSource: false
12:35:06,718 INFO [STDOUT] [2009:01:13 12:01:718:debug] KnowledgeAgent
adding KnowledgeDefinitionsPackage regulation
12:35:06,843 INFO [STDOUT] [2009:01:13 12:01:843:debug] KnowledgeAgent
building resource map
...
as you can see, there is this line saying that it failed to read the
schema-document. I don't know whether this could cause the problem I have
right now: although a rule in the package regulation should fire (it is as
easy as to check if "number < 5" then print out something), and I have
indeed input a number smaller than 5, but it didn't.
It also has those PackageIsLatest/PackageIsSource are "false" (how to get
them set to true? at least for PackageIslatest)
my code looks like this:
public List<String> getViolatedRegulation(final List<Activity> activities )
{
LOG.info("Checking rules ... ");
final List<String> violatedRegulation = new ArrayList<String>();
this.ksession = this.getSession();
this.ksession.setGlobal("violatedRegulation", violatedRegulation);
this.ksession.executeObject(new Object[] {activities});
return violatedRegulation;
}
(An activity object has an attribute "number": a rule checks whether the
number < 5)
private StatelessKnowledgeSession getSession() {
LOG.info("Getting session for Rules Engine ...");
// Set the interval on the ResourceChangeScannerService if you are to use
it
// and default of 60s is not desirable.
final ResourceChangeScannerConfiguration sconf =
ResourceFactory.getResourceChangeScannerService()
.newResourceChangeScannerConfiguration();
// set the disk scanning interval to 30s, default is 60s
sconf.setProperty("drools.resource.scanner.interval", "30");
ResourceFactory.getResourceChangeScannerService().configure(sconf);
this.kbase = KnowledgeBaseFactory.newKnowledgeBase();
final KnowledgeAgentConfiguration aconf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
// we want to scan directories, not just files, turning this on turns on
file
// scanning
aconf.setProperty("drools.agent.scanDirectories", "true");
// resource changes results in a new instance of the KnowledgeBase being
// built, this cannot currently be set to false for incremental building
aconf.setProperty("drools.agent.newInstance", "true");
final KnowledgeAgent kagent =
KnowledgeAgentFactory.newKnowledgeAgent("kagent", this.kbase,
aconf);
kagent.applyChangeSet(ResourceFactory.newFileResource("c:/changeset.xml"));
return kagent.getKnowledgeBase().newStatelessKnowledgeSession();
}
changeset.xml looks as follows:
<change-set
xmlns='http://drools.org/drools-5.0/change-set'
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
xs:schemaLocation='http://drools.org/drools-5.0/change-set
drools-change-set-5.0.xsd'>
<add>
<resource
source='http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/regulation/regulation'
type='PKG' />
</add>
</change-set>
Thanks for any explanation
Regards
Paul
--
View this message in context:
http://www.nabble.com/Problem-using-BRMS-and-Knowledge-Agent-tp21434310p2...
Sent from the drools - user mailing list archive at
Nabble.com.