Bug 1117114

Summary: BRMS restricts usage to Maven projects only
Product: [Retired] JBoss BRMS Platform 6 Reporter: Vikram Goyal <vigoyal>
Component: ConfigurationAssignee: Mario Fusco <mfusco>
Status: CLOSED EOL QA Contact: Marek Winkler <mwinkler>
Severity: unspecified Docs Contact: Dawn Eisner <deisner>
Priority: medium    
Version: 6.0.2CC: erics, kverlaen, mwinkler, rrajasek
Target Milestone: DR2   
Target Release: 6.1.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-27 19:44:10 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Vikram Goyal 2014-07-08 05:14:24 UTC
I am not sure if this is a design feature or not but I have found that it is impossible to create a BRMS project outside of a Maven structure (and by that I mean the presence of a pom.xml in the CLASSPATH).

If this is intentional and the BRMS engine (and by extension the BPMS Engine) shouldn't be used outside a MAVEN structure then we should document this (and yes, please go ahead and reassign this bug to me :)).

Bug Details:

I have tried to load a KContainer and start a KSession using this code in an independent java file (outside of an IDE and using a text editor).

import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;

public class MyFirstRule {
  public static void main(String args[]) {
     KieServices ks = KieServices.Factory.get();
        KieContainer kContainer = ks.getKieClasspathContainer();
        KieSession kSession = kContainer.newKieSession();
  }
}

I have then created an empty kmodule.xml:

<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule"/>

and put it in the following folder:

./META-INF

I then compiled it using:

javac -cp .:./brms-files/jboss-brms-engine/* MyFirstRule.java

The jboss-brms-engine folder contains all the jar files provided by the jboss-generic-deployable.

Compilation is successful but running it using the following command:

java -classpath .:./brms-files/jboss-brms-engine/* MyFirstRule

gives the following error:

Exception in thread "main" java.lang.RuntimeException: Cannot find a default KieSession
	at org.drools.compiler.kie.builder.impl.KieContainerImpl.findKieSessionModel(KieContainerImpl.java:450)
	at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:443)
	at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:426)
	at MyFirstRule.main(MyFirstRule.java:10)


The error is misdirected - the actual error comes from the inability by the engine to find a pom.xml.

In the above code, when the KieServices calls the method getKieClasspathContainer() - it eventually calls the fetchKModule(URL url, String fixedURL) method in ClasspathKieProject class. This is where the system assumes that there will be a POM file present. 

Since this is a non Maven project, a POM file is not found, and when the following call is made in this method, exceptions occur but are simply logged and not propagated. This causes the system to assume that loading of POM properties worked when it didn't.

String pomProperties = getPomProperties( fixedURL );

The result is that the original code fails with a different error from what actually occurred. The actual error is that the system can't find a POM file, but the error that is reported is that no default ksession was found.

I believe this should be fixed by either:

a) fixing the code to remove the reliance on the presence of a POM file (and by extension enabling non Maven projects to be built using the BRMS engine).

b) declaring it in documentation that BRMS/BPMS is not supported on non Maven projects.

If you choose b, please change the component of this bug to Documentation so that we can cover it for an async-release.

Comment 2 Mario Fusco 2014-07-08 18:17:29 UTC
This issue has been already fixed on master/6.1.x with this commit https://github.com/droolsjbpm/drools/commit/1fb4c12d133e576dd9669406ac5c238fcb3cf8a0

Comment 3 Marek Winkler 2014-09-29 15:49:49 UTC
Verified on BRMS 6.1.0.DR3.