title: cannot load drools rule, getting error: unable to resolve object type
body: <p>i'm new to drools, i'm trying to run the hello world but it keeps giving me this error</p>
  
  <blockquote>
    <p>Some errors exists in packageBuilder
    Unable to resolve ObjectType 'Messagee' : [Rule name='Hello World']</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalArgumentException: Could
  not parse knowledge.
  at hellodrools.HelloWorldRuleTest.initialiseDrools(HelloWorldRuleTest.java:55)
  at hellodrools.HelloWorldRuleTest.main(HelloWorldRuleTest.java:26)
  </code></pre>
    
    <p>Rule Compilation error : [Rule name='Hello World']
      hellodrools/Message/Rule_Hello_World720710180.java (1:8) : The
    package hellodrools.Message collides with a type</p>
  </blockquote>
  
  <p>my drl file:</p>
  
  <pre><code>package hellodrools.Message
  rule 'Hello World'
  when
  message:Message (type == 'Hello')
  then
  message.printMessage();
  end
  </code></pre>
  
  <p>Message.java</p>
  
  <pre><code>package hellodrools;
  
  public class Message{
  
      private String type;
  
      public String getType() {
          return type;
      }
  
      public void setType(String type) {
          this.type = type;
      }
  
      public void printMessage() {
          System.out.println("Type: " + type);
      }
  }
  </code></pre>
  
  <p>HelloWorldTestRule.java</p>
  
  <pre><code>package hellodrools;
  
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.Reader;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  import org.drools.core.RuleBase;
  import org.drools.core.RuleBaseFactory;
  import org.drools.core.StatefulSession;
  import org.drools.compiler.compiler.DroolsParserException;
  import org.drools.compiler.compiler.PackageBuilder;
  import org.drools.compiler.compiler.PackageBuilderErrors;
  import hellodrools.Message;
  
  
  public class HelloWorldRuleTest {
      private static RuleBase rbase = RuleBaseFactory.newRuleBase();;
      private static PackageBuilder pbuilder = new PackageBuilder();
      private static StatefulSession sessionObject;
      private static String DRL_FILE = "/helloWorld.drl";
  
  
  
      public static void main(String[] args) {
          initialiseDrools();
          initiliseMessageObject();
          runRules();
      }
  
      // Method to initialise the package builder and add package to the rule
      // base.
      private static void initialiseDrools() {
          // 1. Read the DRL File and add to package builder
          try {
              Reader reader = new InputStreamReader(
                      HelloWorldRuleTest.class.getResourceAsStream(DRL_FILE));
              pbuilder.addPackageFromDrl(reader);
          } catch (DroolsParserException ex) {
              Logger.getLogger(HelloWorldRuleTest.class.getName()).log(
                      Level.SEVERE, null, ex);
          } catch (IOException ex) {
              Logger.getLogger(HelloWorldRuleTest.class.getName()).log(
                      Level.SEVERE, null, ex);
          }
  
          // 2. Check for any errors
          PackageBuilderErrors errors = pbuilder.getErrors();
  
          if (errors.getErrors().length &gt; 0) {
              System.out.println("Some errors exists in packageBuilder");
              for (int i = 0; i &lt; errors.getErrors().length; i++) {
                  System.out.println(errors.getErrors()[i]);
              }
              throw new IllegalArgumentException("Could not parse knowledge.");
          }
  
          // 3. Add package to rule base
          try {
              rbase.addPackage(pbuilder.getPackage());
          } catch (Exception e) {
              System.out.println("Error: " + e);
          }
      }
  
      // Method to insert message object in session
      private static void initiliseMessageObject() {
          Message msg = new Message();
          msg.setType("Hello");
          sessionObject = rbase.newStatefulSession();
          sessionObject.insert(msg);
      }
  
      // Method to fire all rules
      private static void runRules() {
          sessionObject.fireAllRules();
      }
  }
  </code></pre>