Assuming a proper classpath, the attached jar file runs from the commandline.

 

java -cp test-case.jar TestDrive

 

I suspect your issue may stem from the setup code calling your rule instead of the rules themselves. I’ve included source code in the jar file, but I'll include it inline in this message for reference sake as well.

 

      public static void main(String[] args) throws Exception {

            KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

            kbuilder.add(ResourceFactory.newClassPathResource("test/rule.drl"),ResourceType.DRL);

            if (kbuilder.hasErrors()) {

                  throw new Exception(kbuilder.getErrors().toString());

            }

 

            KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();

            kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());

           

            StatelessKnowledgeSession session = kbase.newStatelessKnowledgeSession();

           

            Message testMessage = new Message();

            testMessage.setMessage("Hello");

           

            session.execute(testMessage);

      }

 

 

Macon

 

 

-----Original Message-----
From: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of satyasri.ch
Sent: Monday, October 26, 2009 6:34 AM
To: rules-users@lists.jboss.org
Subject: [rules-users] Rule is not firing

 

 

Hi ,

 

I am doing the sample drools project.

 

Below are the sample rule and Fact class.

 

when Running from eclipse ide both rules are working fine.

Where as running the rule outside eclipse  ide only second rule fired .

 

Suggest me any ideas

 

 

----------------------------------------------------------

package test

import test.Message;

 

 

rule "Your First Rule"

dialect "mvel"

when

m:Message(  )

eval(m.getMessage() == "Hello")

then

System.out.println("First Rule fired    ");

end

 

rule "Your Second Rule"

dialect "mvel"

when

eval(true)

then

System.out.println("Second Rule fired    ");

end

 

------------------------

 

package test;

public class Message{

private String message;

public String getMessage(){

return this.message;

}

 

public void setMessage(String message) {

this.message = message;

}

 

}

 

 

Thanks,

Satyasri.

--

View this message in context: http://www.nabble.com/Rule-is-not-firing-tp26056180p26056180.html

Sent from the drools - user mailing list archive at Nabble.com.

 

_______________________________________________

rules-users mailing list

rules-users@lists.jboss.org

https://lists.jboss.org/mailman/listinfo/rules-users