As I said “When I start the project it looks like working” I meant that when I “Run” the project then all rules are executed.

I see my dump message “MY LOCAL RULE” so it’s obviously run the local one and the result is as expected.

 

But when I “Debug as drools application” then:

Exception in thread "main" org.drools.RuntimeDroolsException: [Error: not a statement, or badly formed structure]

[Near : {... Unknown ....}]

             ^

[Line: 1, Column: 0]

      at org.drools.agent.PackageProvider.applyChanges(PackageProvider.java:87)

      at org.drools.agent.RuleAgent.refreshRuleBase(RuleAgent.java:397)

      at org.drools.agent.RuleAgent.configure(RuleAgent.java:347)

      at org.drools.agent.RuleAgent.init(RuleAgent.java:247)

      at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:187)

      at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:147)

      at com.mtel.mdf.base.model.transformation.rules.RuleBaseManager.loadRulebasesDefinition(RuleBaseManager.java:86)

      at com.mtel.mdf.base.model.transformation.rules.RuleBaseManager.<init>(RuleBaseManager.java:41)

      at com.mtel.mdf.base.model.transformation.rules.RuleBaseManager.getRuleBaseManager(RuleBaseManager.java:30)

      at com.mtel.mdf.base.model.transformation.MDFTransformer.createRuleBaseManager(MDFTransformer.java:240)

      at com.mtel.mdf.base.model.transformation.MDFTransformer.<init>(MDFTransformer.java:85)

      at com.mtel.mdf.mapping.o2p.O2PTransformer.<init>(O2PTransformer.java:8)

      at com.mtel.mdf.mapping.o2p.O2PTransformerFactory.createTransformer(O2PTransformerFactory.java:17)

      at com.mtel.mdf.base.MDFFactory.createTransformer(MDFFactory.java:32)

      at com.mtel.mdf.mapping.o2p.test.O2PModeltransformerTest.test_mdf_base(O2PModeltransformerTest.java:51)

      at com.mtel.mdf.mapping.o2p.test.O2PModeltransformerTest.main(O2PModeltransformerTest.java:38)

Caused by: [Error: not a statement, or badly formed structure]

[Near : {... Unknown ....}]

             ^

[Line: 1, Column: 0]

      at org.mvel2.compiler.ExpressionCompiler._compile(ExpressionCompiler.java:257)

      at org.mvel2.compiler.ExpressionCompiler.compile(ExpressionCompiler.java:58)

      at org.drools.base.mvel.MVELCompilationUnit.compile(MVELCompilationUnit.java:355)

      at org.drools.base.mvel.MVELCompilationUnit.getCompiledExpression(MVELCompilationUnit.java:282)

      at org.drools.base.mvel.MVELConsequence.compile(MVELConsequence.java:49)

      at org.drools.rule.MVELDialectRuntimeData.onBeforeExecute(MVELDialectRuntimeData.java:103)

      at org.drools.rule.DialectRuntimeRegistry.onBeforeExecute(DialectRuntimeRegistry.java:113)

      at org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:456)

      at org.drools.reteoo.ReteooRuleBase.addPackage(ReteooRuleBase.java:394)

      at org.drools.agent.PackageProvider.applyChanges(PackageProvider.java:85)

      ... 15 more

Caused by: java.lang.NullPointerException

      at org.mvel2.compiler.CompiledExpression.<init>(CompiledExpression.java:51)

      at org.mvel2.compiler.ExpressionCompiler._compile(ExpressionCompiler.java:253)

      ... 24 more

 

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

Anyone who meet the same problem ?

I don’t see any wrong expression…

 

Thanks & Best Regards

Ivan

 

From: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Ivan Peshev ( M-Tel )
Sent: Monday, August 08, 2011 3:03 PM
To: Rules Users List
Subject: Re: [rules-users] RuleAgent - loading rules help ?

 

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