Pritham, I've experienced this issue before as well. It has to do with the way that the KnowledgeAgent subscribes to resources. I believe behind the scenes the resources are loaded in an arbitrary order. There is a JIRA bug report already filed:
https://jira.jboss.org/jira/browse/JBRULES-2377 Hope this helps, Steve rules-users-boun...@lists.jboss.org wrote on 01/26/2010 01:07:29 PM: > [image removed] > > [rules-users] KnowledgeAgent doesn't load dsl files and dslr file > from a change-set correctly > > Pritham > > to: > > rules-users > > 01/26/2010 01:10 PM > > Sent by: > > rules-users-boun...@lists.jboss.org > > Please respond to Rules Users List > > > I have a folder in classpath: > > dsl/global.dsl > rules/section-A.dslr > rules/section-A/page-1.dslr > > I create a knowledge base like this: > > public KnowledgeBase createKnowledgeBase() throws DroolsParserException, > IOException { > > KnowledgeBuilder knowledgeBuilder = KnowledgeBuilderFactory > .newKnowledgeBuilder(); > > knowledgeBuilder.add(ResourceFactory > .newClassPathResource("dsl/global.dsl"), > ResourceType.DSL); > knowledgeBuilder.add(ResourceFactory > .newClassPathResource("rules/section-A.dslr"), > ResourceType.DSLR); > knowledgeBuilder.add(ResourceFactory > .newClassPathResource("rules/section-A/page-1.dslr"), > ResourceType.DSLR); > > if (knowledgeBuilder.hasErrors()) { > throw new RuntimeException(knowledgeBuilder.getErrors().toString()); > } > > KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(); > > knowledgeBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages()); > > return knowledgeBase; > } > > // code > knowledgeBase = createKnowledgeBase(); > session = knowledgeBase.newStatefulKnowledgeSession(); > // insert facts > session.fireAllRules(); > session.dispose(); > > The above code works and I can get a unit test to work that processes rules > accordingly. I can see my dslr converting to a drl using the "drl viewer" > correctly (provided I temporarily place the dsl file in the same location > since expander doesn't accept a relative path). > > The problem, however is when I use a change-set.xml and a KnowledgeAgent, > things don't work > > code for loading via knowledgeAgent > > public static KnowledgeBase loadKnowledgeBase() throws > DroolsParserException, IOException { > agent = KnowledgeAgentFactory.newKnowledgeAgent("msll agent"); > > agent.applyChangeSet(ResourceFactory.newClassPathResource("change-set.xml")); > > return agent.getKnowledgeBase(); > } > > > <change-set xmlns='http://drools.org/drools-5.0/change-set' > xmlns:xs='http://www.w3.org/2001/XMLSchema-instance' > xs:schemaLocation='http://drools.org/drools-5.0/change-set.xsd' > > > <add> > <resource source='classpath:dsl/' type='DSL' /> > <resource source='classpath:rules/' type='DSLR' /> > <resource source='classpath:rules/section-A/' type='DSLR' /> > </add> > </change-set> > > > I get the following generic drools errors: > ERR 103] Line 4:0 rule 'rule_key' failed predicate: > {(validateIdentifierKey(DroolsSoftKeywords.RULE))}? in rule[7,0]: [ERR 101] > Line 7:0 no viable alternative at input 'import' in rule Con in rule > attribute > ... > ... > > The rules are same, folder location is the same. I believe that drools has a > problem resolving path (expander global.dsl) from the dslr file when using a > KnowlegeAgent since in the earlier strategy, one could build a dsl into the > knowledgeBuilder directly from the classpath. > > Pl suggest. > -- > View this message in context: http://n3.nabble.com/KnowledgeAgent- > doesn-t-load-dsl-files-and-dslr-file-from-a-change-set-correctly- > tp139702p139702.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
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users