stellina_rosa [
http://community.jboss.org/people/stellina_rosa] created the discussion
"Unable to create Field Extractor"
To view the discussion, visit:
http://community.jboss.org/message/606688#606688
--------------------------------------------------------------
h6. Hi!
h6. I'm trying to create an example Drools file but when I run it I have this error
message:
h6.
h6.
h6. Unable to create Field Extractor for 'contenuto' of '[ClassObjectType
class="java".lang.Object]' in rule 'prova' : [Rule
name='prova']
java.lang.IllegalArgumentException: Could not parse knowledge.
at
org.drools.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilderImpl.java:58)
at com.sample.ProcessTest.readKnowledgeBase(ProcessTest.java:43)
at com.sample.ProcessTest.main(ProcessTest.java:21)
h6. this is my drools file (named Rule.drl):
package com.googlecode.cursos.jbpm
import org.drools.runtime.process.WorkflowProcessInstance;
import org.sample.model.MyObject;
rule "prova"
ruleflow-group "regole"
when
$o: Object(contenuto == "rosa")
then
System.out.println("prima regola");
end
h6. this is my ProcessTest.java class:
public class ProcessTest {
public static final void main(String[] args) {
try {
// load up the knowledge base
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
MyObject obj = new MyObject();
obj.setContenuto("rosa");
obj.setId(1);
ksession.insert(obj);
// start a new process instance
ksession.startProcess("com.sample.bpmn.hello");
ksession.fireAllRules();
logger.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("sample.bpmn"),
ResourceType.BPMN2);
kbuilder.add(ResourceFactory.newClassPathResource("Rule.drl"),
ResourceType.DRL);
return kbuilder.newKnowledgeBase();
}
h6. and this is my MyObject.java class:
package org.sample.model;
public class MyObject {
String contenuto;
int id;
public int getId() { return id;}
public void setId(int id) { this.id = id; }
public String getContenuto() { return contenuto; }
public void setContenuto(String contenuto) { this.contenuto = contenuto;}
}
I can't understand where is the problem :(
could anyone help me please?
thank you!
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/606688#606688]
Start a new discussion in jBPM at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]