[JBoss Rules with DSL] Unable to expand
tom.collet Apr 17, 2009 10:24 AMHi there,
I'm a newbie on Jboss and I try to use a basic DSL with a basic rule :
My DSL file called TctMyDSL.dsl :
---------------------------------------
[consequence][]print "{message}"=System.out.println("{message}");
My DRL file :
---------------
package tom import java.util.Date; expander TctMyDSL.dsl rule "TctMyRule2" when then print : "TctMyRule2-->then" end
To fire my rule, I use a servlet deployed on a jboss-4.0.5.GA server / Vista and using the java 1.5 version :
My Servlet :
--------------
imports ... /** * Servlet implementation class for Servlet: TctMyServlet * */ public class TctMyRulesServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet { static final long serialVersionUID = 20101986; protected static RuleEngine ruleEngine = RuleEngine.getInstance(); private static Logger log = Logger.getLogger(TctMyRulesServlet.class); /* (non-Java-doc) * @see javax.servlet.http.HttpServlet#HttpServlet() */ public TctMyRulesServlet() { super(); } /* (non-Java-doc) * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Space space = Space.newInstance(); space.write(EventI.SP_NOW, new Date()); RuleSession mem = ruleEngine.createSession(null, "TctMyRuleBase"); mem.addFact((Date)space.read(EventI.SP_NOW)); try{ mem.processFacts(); }catch(Exception e){ log.info("Tom say : "+e.getMessage()); } } /* (non-Java-doc) * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doGet(request, response); } }
And so I am getting the following error :
unknown:11:0 Unable to expand: print "TctMyRule2-->then". Due to Expression was not expandable: print "TctMyRule2-->then"
For the moment I don't use my fact to fire my rule (when block is empty) as i'm debugging but in the future I would have something like this :
My future DRL file :
----------------------
package tom import java.util.Date; expander TctMyDSL.dsl rule "TctMyRule2" when now : Date() then print : "message" end
Without DSL file my rules work fine.
Also I have made a lot of research but I get only solutions for punctuation problems like added spaces, missing expander ...
Thank you for your help and please accept my apologies for the bad English :-)
Tom.