Bug 733111

Summary: Rules Not Loading in Deployed Application
Product: [JBoss] JBoss Enterprise BRMS Platform 5 Reporter: Will Dinyes <wdinyes>
Component: DeploymentAssignee: Julian Coleman <jcoleman>
Status: CLOSED EOL QA Contact: Lukáš Petrovický <lpetrovi>
Severity: high Docs Contact:
Priority: unspecified    
Version: BRMS 5.2.0-ER1CC: brms-jira
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Windows   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-07-02 11:31:23 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Example code
none
Full stack trace of load. none

Description Will Dinyes 2011-08-24 19:26:44 UTC
Created attachment 519697 [details]
Example code

Description of problem:
This was run on BRMS 5.2 ER2.  Here's the code:

// Initialize the kbase here, since we just need to do that once for the application
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

// Loading our changesets from the app server
Resource changeset = ResourceFactory.newUrlResource("http://localhost:8080/JBTravelApp/UnifiedChangeSet.xml");
kbuilder.add(changeset, ResourceType.CHANGE_SET);

// Send any errors to our Seam logger.
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
    for (KnowledgeBuilderError error : errors) {
        log.error(changeset.toString());
        log.error(error.getMessage());
    }
    throw new IllegalArgumentException("Could not parse knowledge.");
}

// Setting configs
KnowledgeBaseConfiguration kbaseConfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
kbaseConfig.setOption(SequentialOption.NO);
kbase = KnowledgeBaseFactory.newKnowledgeBase(kbaseConfig);
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());


// Prints out KnowledgeBase contents - we send it to our Seam logger as info.
Collection<KnowledgePackage> pkgs = kbase.getKnowledgePackages();
log.info("Number of packages: ", kbuilder.getKnowledgePackages().size());
for (KnowledgePackage pkg : pkgs) {
    // Consider sending as debug, since we don't always care . . .
    log.info("* " + pkg.getName());
    Collection<Rule> rules = pkg.getRules();
    for (Rule rule : rules) {
        log.info("   - " + rule.getName());
    }
}


Basically, that loads from a change set, which is apparently the recommended way to do this.

When you run this, here's what you get for output:

07:25:10,865 INFO  [TransientRepository] Session closed
07:25:10,865 INFO  [TransientRepository] Session opened
07:25:10,865 INFO  [TransientRepository] Session closed
07:25:10,876 INFO  [TransientRepository] Session opened
07:25:10,876 INFO  [RepositoryServlet] admin authenticated for rest api
07:25:10,876 INFO  [RepositoryServlet] PackageName: biz.jbtravel.insurance
07:25:10,876 INFO  [RepositoryServlet] PackageVersion: LATEST
07:25:10,876 INFO  [RepositoryServlet] PackageIsLatest: true
07:25:10,876 INFO  [RepositoryServlet] PackageIsSource: false
07:25:10,920 INFO  [TransientRepository] Session closed
07:25:10,920 INFO  [TransientRepository] Session opened
07:25:10,931 INFO  [TransientRepository] Session closed
07:25:12,231 INFO  [TransientRepository] Session opened
07:25:12,231 INFO  [RepositoryServlet] admin authenticated for rest api
07:25:12,231 INFO  [RepositoryServlet] PackageName: biz.jbtravel.meals
07:25:12,231 INFO  [RepositoryServlet] PackageVersion: LATEST
07:25:12,231 INFO  [RepositoryServlet] PackageIsLatest: true
07:25:12,231 INFO  [RepositoryServlet] PackageIsSource: false
07:25:12,352 INFO  [TransientRepository] Session closed

There are others, but this looks like it's loading the rules just fine, and I can confirm that the service is definitely sending *something* (if I use the URL in the change set directly, I get some binary Java package stuff).  I get no errors from my errors block above, so I think all is well.  However, the next error I get is this:

Caused by: java.lang.NullPointerException
       at jbtravel.session.lab.KnowledgeComponent.<init>(KnowledgeComponent.java:59)

Here's line 59 (from above):

log.info("Number of packages: ", kbuilder.getKnowledgePackages().size());

Apparently, the rules packages are completely empty.  The collection is missing.  I have also tested this against loading from an application-local bundle, under WEB-INF/classes, and gotten the same results.  Replacing the KnowledgeBuilder with a KnowledgeAgent similarly produces the exception.

Version-Release number of selected component (if applicable):
5.2.0-ER2

How reproducible:
Highly


Steps to Reproduce:
1. Create a Seam component in an existing Seam application that wraps a KnowledgeBase
2. Make the component Application scoped, and set @Startup
3. In constructor, add the code above
4. Ensure change set and rules files are available under WEB-INF/classes
5. Deploy to BRMS server instance

Actual results:
Null pointer exception

Expected results:
Rules should load properly and be ready for use.

Additional info:
The same code used to run rules in a JUnit test local to JBDS works perfectly.

Comment 1 Will Dinyes 2011-08-24 19:27:37 UTC
Created attachment 519699 [details]
Full stack trace of load.

Stack trace resulting from above example code deployment.

Comment 2 lcarlon 2011-09-15 06:51:49 UTC
Julian is this something you would like a release note for?