2 Replies Latest reply on May 24, 2011 5:59 AM by stellina_rosa

    Unable to create Field Extractor

    stellina_rosa Newbie
      I'm trying to create an example Drools file but when I run it I have this error message:
      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)



      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"


                          $o: Object(contenuto == "rosa")


                 System.out.println("prima regola");





      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();




                                    // start a new process instance





                          } catch (Throwable t) {





      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();




      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!