Here is some more details:
· Currently our system loads rules from Guvnor installed on a server (version 5.0.0)
The problem is that there is no way to debug remotely the rules which are already deployed on Guvnor.
So I was wondering “what if I load the rule I need to debug from my local machine instead…. maybe then I’ll be able to debug it…”
· On my local machine I have drools 5.1.0
Here is part of the original code:
--------------------------------
public synchronized void loadRulebasesDefinition() {
ruleBaseList = RulesMapper.getRulesMapper().retrieveAllRuleBases();
for (Entry<Integer, Rule> entry : ruleBaseList.entrySet()) {
Rule currentRuleDefinition = entry.getValue();
Properties ruleBaseProperties = createRuleBaseProperties(currentRuleDefinition);
RuleAgent agent = RuleAgent.newRuleAgent(ruleBaseProperties);
currentRuleDefinition.setRuleBase(agent.getRuleBase());
}
}
private Properties createRuleBaseProperties(Rule ruleDefinition) {
Properties properties = new Properties();
properties.setProperty("url", ruleDefinition.getRuleBaseURL());
properties.setProperty("poll", Integer.toString(ruleDefinition.getRuleBasePoll()));
return properties;
}
--------------------------------
The info about the rules is retrieved by the Mapper class from a DB and the result is a map:
Map<Integer, Rule> ruleBaseList
--------------------------------
So I modified the loadRulebasesDefinition() method and I changed the url info in the DB for some of the rules to start with “local:” and to point to a location on my machine:
----------------------------------
public synchronized void loadRulebasesDefinition() {
ruleBaseList = RulesMapper.getRulesMapper().retrieveAllRuleBases();
for (Entry<Integer, Rule> entry : ruleBaseList.entrySet()) {
Rule currentRuleDefinition = entry.getValue();
Properties ruleBaseProperties = createRuleBaseProperties(currentRuleDefinition);
if (ruleBaseProperties.getProperty("url").startsWith("local:"))
{
try {
String path = ruleBaseProperties.getProperty("url").replaceAll("local:", "");
File file = new File(path);
Reader source = new InputStreamReader(new FileInputStream(file));
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( source );
org.drools.rule.Package pkg = builder.getPackage();
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );
currentRuleDefinition.setRuleBase(ruleBase);
} catch (DroolsParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else
{
RuleAgent agent = RuleAgent.newRuleAgent(ruleBaseProperties);
currentRuleDefinition.setRuleBase(agent.getRuleBase());
}
}
}
--------------------------------
When I start the project it looks like working,
But when I try to “debug as Drools application” it goes to some point – loads some rules from URLs etc
– and boom:
Exception in thread "main" org.drools.RuntimeDroolsException: [Error: not a statement, or badly formed structure]
[Near : {... Unknown ....}]
Any idea ?
Thanks & Best regards
Ivan
From: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Esteban Aliverti
Sent: Monday, August 08, 2011 1:32 PM
To: Rules Users List
Subject: Re: [rules-users] RuleAgent - loading rules help ?
Which version of drools are you using?
If you are using a change-set to feed you kagent, then you can use other protocols rather than http to get your rules from: file://, classpath://
Best Regards,
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com
2011/8/8 Ivan Peshev ( M-Tel ) <ivan.peshev@mobiltel.bg>
Hello,
Is there a way to tell RuleAgent to load rules not only from remote URL ?
i.e. some rules from URL and some rules from LOCAL path on my computer.
(e.g.: c:\some\folder\rule.drl)
Or if it’s not possible exactly that way is there another way to have some rules loaded from URLs and some rules loaded from local path ?
Best Regards
Ivan
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users