No error is reported even if rules are not loaded correctly due to inconsystency of Data Model.

Solution Unverified - Updated -

Issue

When running Drools application developed by JBDS and it also has Data Model with the project which is inconsistent with the one referenced by rules in kjar, building kieBase complete without any error/warning message even if no rule is loaded due to inconsistency of data model

Here is snippet of code.

        String groupId      = "com.sample";
        String artifactId   = "Test";
        String versionId    = "RELEASE";

        System.out.println("*** debug *** groupId    = "+ groupId);
        System.out.println("*** debug *** artifactId = "+ artifactId);
        System.out.println("*** debug *** versionId  = "+ versionId);


    KieServices ks = KieServices.Factory.get();

    ReleaseId releaseId = ks.newReleaseId( groupId, artifactId, versionId );
        KieContainer kContainer = ks.newKieContainer( releaseId );
        KieSession kSession =  kContainer.newKieSession();

        int ruleCount = 0;
    for (KiePackage kiePackage : kSession.getKieBase().getKiePackages())
    {
         ruleCount += kiePackage.getRules().size();
    }

        System.out.println( ruleCount + " rules(s) loaded");

If this run with BRMS6.0.3 libraries, no message is shown even if no rules is loaded.

*** debug *** groupId    = com.sample
*** debug *** artifactId = Test
*** debug *** versionId  = RELEASE
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
0 rule(s) loaded 

But if this run with BRMS6.1.0 (and later) libraries, the following error message is shown as expected.

*** debug *** groupId    = com.sample
*** debug *** artifactId = Test
*** debug *** versionId  =  RELEASE
Sep 02, 2015 12:08:29 PM org.kie.scanner.embedder.MavenSettings initSettings
WARNING: Environment variable M2_HOME is not set
Sep 02, 2015 12:08:32 PM org.drools.compiler.kie.builder.impl.AbstractKieModule getCompilationCache
WARNING: The compilation cache has been built with an incompatible version. You should recompile your project in order to use it with current release.
Sep 02, 2015 12:08:33 PM org.drools.compiler.kie.builder.impl.AbstractKieModule buildKnowledgePackages
SEVERE: Unable to build KieBaseModel:defaultKieBase
Unable to create Field Extractor for 'c'Field/method 'c' not found for class 'com.sample.fact.Fact'
 : [Rule name='Rule1']
java.lang.RuntimeException: Field/method 'c' not found for class 'com.sample.fact.Fact'

Unable to Analyse Expression c == 1:
[Error: unable to resolve method using strict-mode: com.sample.fact.Fact.c()]
[Near : {... c == 1 ....}]
             ^
[Line: 7, Column: 2] : [Rule name='Rule1']

0 rule(s) loaded

Environment

  • Red Hat JBoss Business Rule Management System (BRMS)
    • 6.0.3

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In