[jboss-user] [jBPM] - Unable to create Field Extractor

stellina_rosa do-not-reply at jboss.com
Tue May 24 05:17:31 EDT 2011


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&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110524/836b9e1d/attachment.html 


More information about the jboss-user mailing list