Bug 733111 - Rules Not Loading in Deployed Application
Summary: Rules Not Loading in Deployed Application
Keywords:
Status: CLOSED EOL
Alias: None
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: Deployment
Version: BRMS 5.2.0-ER1
Hardware: i686
OS: Windows
unspecified
high
Target Milestone: ---
: ---
Assignee: Julian Coleman
QA Contact: Lukáš Petrovický
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-08-24 19:26 UTC by Will Dinyes
Modified: 2018-07-02 11:31 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-07-02 11:31:23 UTC
Type: ---


Attachments (Terms of Use)
Example code (2.66 KB, text/x-java)
2011-08-24 19:26 UTC, Will Dinyes
no flags Details
Full stack trace of load. (29.64 KB, text/plain)
2011-08-24 19:27 UTC, Will Dinyes
no flags Details

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?


Note You need to log in before you can comment on or make changes to this bug.