Java project packaged as jar containing another drools project as dependency does not start

I have a maven Spring-boot project named "controller" which has another "webservices" project as a dependency. "webservices" is the Drools project (kmodule.xml is located in the src / main / resources / META-INF / directory inside the webservices project).

Now when I run my controller project from Eclipse it works fine. However, when I jar it and try to run it with java -jar controller.jar

, it says Found kmodule: jar:file:controller-0.1.jar!/lib/webservices-0.1.jar!/META-INF/kmodule.xml

and after that it gets stuck. It doesn't throw any errors. But it doesn't start either.

What's wrong here? It can find the kmodule file, so this is not a problem. Why doesn't it start?

=============== Update =================

It starts, but it takes almost half an hour to recover. I used to have web services as a separate project and it started in about 3 minutes. However, it stopped at the same step for about 2 minutes. Now, half an hour later, I get this log:

o.d.c.k.b.i.KieRepositoryImpl - KieModule was added:ZipKieModule[ ReleaseId=controller:0.1file=Desktop/controller-0.1.jar]

      

And then it starts right away.

============== Update 2 =================

I tried to move the kmodule.xml file and rules file to the "controller" project, build a KSession object in the controller and pass it to the webservices project. It still takes half an hour.

This is my project structure:

controller
  |__ src/main/java
  |__ src/main/resources
         |__ rules
               |__ mypkg1
                     |__ rules1.drl
               |__ mypkg2
                     |__ rules2.drl
         |__ META-INF
               |__ kmodule.xml

      

My kmodule.xml file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://jboss.org/kie/6.0.0/kmodule">
    <kbase name="Kbase1" packages="rules.mypkg1.rules">
        <ksession name="abc" type="stateless"/>
    </kbase>
    <kbase name="Kbase2" packages="rules.mypkg2.rules">
        <ksession name="xyz" type="stateless"/>
    </kbase>
</kmodule>

      

From the controller, I am calling a class in webservices that uses drools. This is how I call the class in the webservices project that uses drools:

public class ControllerClass {
    StatelessKieSession kSession;
    KieServices kieService;
    KieContainer kContainer;

    public ReturnsController() {
        kieService = KieServices.Factory.get();
        kContainer = kieService.getKieClasspathContainer();
    }

    public void callWebservices(String kSessionName){
        kSession = kContainer.newStatelessKieSession(kSessionName);
        WebservicesClass wc = new WebservicesClass();
        wc.callDroolsMethod(kSession);
    }
}

      

The rule files are short, each containing about 10 max rules. Starting the drooling engine directly from the webservices project only takes about 3 minutes. The controller project itself is very lightweight so I doubt it due to the memory issue.

Thank.

+3


source to share





All Articles