KieModule was adding in every kie container creation call to fire rules

1,406 views
Skip to first unread message

Ruler

unread,
Dec 27, 2016, 6:12:12 AM12/27/16
to Drools Usage

Hi All,



Getting below info everytime  in tomcat logs while i am calling rules.
Thread count also increasing in every call like 


[http-nio-8080-exec-10] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=SampleProjectUnit:SampleProject:LATEST,file=/root/.m2/repository/SampleProjectUnit/SampleProject/LATEST/SampleProject-LATEST.jar

Thread count also increasing in every call like 

[http-nio-8080-exec-11] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=SampleProjectUnit:SampleProject:LATEST,file=/root/.m2/repository/SampleProjectUnit/SampleProject/LATEST/SampleProject-LATEST.jar

[http-nio-8080-exec-12] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=SampleProjectUnit:SampleProject:LATEST,file=/root/.m2/repository/SampleProjectUnit/SampleProject/LATEST/SampleProject-LATEST.jar


After multiple requests for 2-3 days, Garbage overhead limit is exceeding


24-Dec-2016 05:28:55.488 SEVERE [ajp-nio-8009-ClientPoller-1] org.apache.tomcat.util.net.NioEndpoint$Poller.run
 java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: GC overhead limit exceeded
SEVERE:Memory usage is low, parachute is non existent, your system may start failing.


Can anyone help me on this.

Thanks,
Subhash.

Edson Tirelli

unread,
Dec 28, 2016, 9:44:33 AM12/28/16
to drools...@googlegroups.com

   How are you invoking the rules? Are they embedded in your application or are you using the kie-server? If you are using the kie-server, can you show us the REST payload or the list of commands you are using if you are using the client API? If it is embedded, can you please show the snippet of code where you are invoking the rules?

   Short explanation is: kie containers are only created when explicitly requested by the application, so there must be an unwanted interaction going on on your code.

   Edson

  

--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage+unsubscribe@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/95095b70-4d99-43fb-90a2-29d55d5badb6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
  Edson Tirelli
  Sr Principal Software Engineer 
  Red Hat Business Systems and Intelligence Group

Ruler

unread,
Dec 29, 2016, 12:21:16 AM12/29/16
to Drools Usage
Hi Edson,

Thank you for helping.

Presently i am using tomcat server in EC2 instance for deploying kie-drools-eb.war. At present i am  not using kie-server.
defined rules with help of data objects and guided decision tables in work bench.

created web services to fire the rules in workbench and deployed that services war file in the same tomcat server

In that web services i am creating kie container as like below. in service i am calling createKieContainer() for every request.

private KieContainer createKieContainer() throws ClientProtocolException, IOException {

final String url = AMConstants.HOST_IP + "/kie-drools-wb/maven2/" + AMConstants.GROUP_ID + "/"
+ AMConstants.ARTIFACT_ID + "/" + "LATEST" + "/" + AMConstants.ARTIFACT_ID + "-" + "LATEST" + ".jar";

KieServices ks = KieServices.Factory.get();
                ks.getResources().newUrlResource(url);

KieContainer kContainer = ks
.newKieContainer(ks.newReleaseId(AMConstants.GROUP_ID, AMConstants.ARTIFACT_ID, "LATEST"));

return kContainer;

}

with this container i am creating ksession to fire rules

final KieContainer kContainer = createKieContainer();
final KieSession kSession = kContainer.newKieSession();
kSession.insert(sampleObject);
kSession.fireAllRules();

after getting the response i am disposing ksession also.

kSession.dispose();

i also configured settings.xml for remote maven in /usr/loca/maven/conf/



Can you help me on this.

Thanks,
Subhash.

Edson Tirelli

unread,
Dec 30, 2016, 10:35:08 AM12/30/16
to drools...@googlegroups.com

   You shouldn't be creating a kie-container per request, as the kie-container is designed to be shared. You create one kie-container, and then create a session per request.

   If you do want to create a kie-container per request (keep in mind this is a heavy operation), then you need to dispose() the kie-container as well.

   My suggestion is for you to use the kie-server, as the kie-server already manages kie-containers for you and exposes rules as REST or JMS services, but if you prefer to do it in your own service application, you will need to add code to manage the kie-container lifecycle.

    Hope this helps,
     Edson


--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage+unsubscribe@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Ruler

unread,
Jan 2, 2017, 1:01:41 AM1/2/17
to Drools Usage
Thanks Edson for help.

for  future applications i will use kie-server.

presently i am deploying my web services application deployed as separate in that tomcat server.

for every request, how i can get reference of that container each time (without creating container every time for each request).
Can you explain in detail about creating  container  and managing container life cycle in java.

presently i need to change the rules in guided decision table dynamically. for that do i need create container every time?

how to dispose kie container?

my kodule. xml in workbench as below



deployment-descriptor file as
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<deployment-descriptor xsi:schemaLocation="http://www.jboss.org/jbpm deployment-descriptor.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <persistence-unit>org.jbpm.domain</persistence-unit>
    <audit-persistence-unit>org.jbpm.domain</audit-persistence-unit>
    <audit-mode>JPA</audit-mode>
    <persistence-mode>JPA</persistence-mode>
    <runtime-strategy>SINGLETON</runtime-strategy>
    <marshalling-strategies/>
    <event-listeners/>
    <task-event-listeners/>
    <globals/>
    <work-item-handlers/>
    <environment-entries/>
    <configurations/>
    <required-roles/>
    <remoteable-classes/>
    <limit-serialization-classes>false</limit-serialization-classes>
</deployment-descriptor>


Thanks,
Subhash.

On Tuesday, December 27, 2016 at 4:42:12 PM UTC+5:30, Ruler wrote:

Ruler

unread,
Jan 2, 2017, 7:47:56 AM1/2/17
to Drools Usage
Any Solution?

i have multiple projects in that workbench. multiple web services war files deployed in that same tomcat server for their respective projects.
spending too much time for this solution.

Thanks,
Subhash.



On Tuesday, December 27, 2016 at 4:42:12 PM UTC+5:30, Ruler wrote:

Edson Tirelli

unread,
Jan 4, 2017, 3:53:17 PM1/4/17
to drools...@googlegroups.com

   Since you are not using the kie-server, you will have to keep the reference to the kie-container and manage it yourself with some kind of registry. If you were using the kie-server, it would do that for you. You can look at the kie-server code for example. 

   If you update your rules, then you either have to create a new kie-container, or you have to update the existing container calling the updateToVersion() method.

   To dispose the container, call the dispose() method.

    Edson

--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage+unsubscribe@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Ruler

unread,
Jan 5, 2017, 1:30:05 AM1/5/17
to Drools Usage
Thanks Edson for help.

I am sending multiple issues whatever i am getting regularly. i know its too long question. just sending all issues in one thread if any are inter related to know the root cause.

I am creating project with version as LATEST. Deploying the rules after modifying it everyday. presently i can able get latest jar from above mention code by creating container for every request. is any way to use updateToVersion() method to get the latest rules without creating new container?

There is no dispose method for kie container in 6.4.0.

Why Thread count number is increasing every time for every request like below. is any issues for performance  by adding kie module every time in every request?

[http-nio-8080-exec-10] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=SampleProjectUnit:SampleProject:LATEST,file=/root/.m2/repository/SampleProjectUnit/SampleProject/LATEST/SampleProject-LATEST.jar

[http-nio-8080-exec-11] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=SampleProjectUnit:SampleProject:LATEST,file=/root/.m2/repository/SampleProjectUnit/SampleProject/LATEST/SampleProject-LATEST.jar
-
-
-
-
[http-nio-8080-exec-900] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=SampleProjectUnit:SampleProject:LATEST,file=/root/.m2/repository/SampleProjectUnit/SampleProject/LATEST/SampleProject-LATEST.jar

and also getting below error for every request when excecuting create container method

[http-nio-8080-exec-7] ERROR org.kie.scanner.embedder.MavenEmbedder - Unable to build MavenEmbedder
org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException
      role: org.apache.maven.execution.MavenExecutionRequestPopulator
  roleHint: 
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:267)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:249)
at org.kie.scanner.embedder.PlexusComponentProvider.lookup(PlexusComponentProvider.java:42)
at org.kie.scanner.embedder.MavenEmbedder.buildMavenExecutionRequest(MavenEmbedder.java:119)
at org.kie.scanner.embedder.MavenEmbedder.<init>(MavenEmbedder.java:90)
at org.kie.scanner.embedder.MavenEmbedder.<init>(MavenEmbedder.java:81)
at org.kie.scanner.embedder.MavenEmbedder.<init>(MavenEmbedder.java:75)
at org.kie.scanner.embedder.MavenProjectLoader.newMavenEmbedder(MavenProjectLoader.java:66)
at org.kie.scanner.embedder.MavenProjectLoader.parseMavenPom(MavenProjectLoader.java:53)
at org.kie.scanner.embedder.MavenProjectLoader.parseMavenPom(MavenProjectLoader.java:49)
at org.kie.scanner.MavenPomModelGenerator.parse(MavenPomModelGenerator.java:33)
at org.drools.compiler.kproject.xml.PomModel$Parser.parse(PomModel.java:110)
at org.drools.compiler.kie.builder.impl.AbstractKieModule.getPomModel(AbstractKieModule.java:427)
at org.drools.compiler.kie.builder.impl.AbstractKieModule.getJarDependencies(AbstractKieModule.java:129)
at org.kie.scanner.MavenClassLoaderResolver.getClassLoader(MavenClassLoaderResolver.java:65)
at org.drools.compiler.kie.builder.impl.KieModuleKieProject.<init>(KieModuleKieProject.java:68)
at org.drools.compiler.kie.builder.impl.KieModuleKieProject.<init>(KieModuleKieProject.java:56)
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildKieModule(KieBuilderImpl.java:222)
at org.kie.scanner.KieRepositoryScannerImpl.build(KieRepositoryScannerImpl.java:221)
at org.kie.scanner.KieRepositoryScannerImpl.buildArtifact(KieRepositoryScannerImpl.java:171)
at org.kie.scanner.KieRepositoryScannerImpl.loadArtifact(KieRepositoryScannerImpl.java:127)
at org.kie.scanner.KieRepositoryScannerImpl.loadArtifact(KieRepositoryScannerImpl.java:122)
at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.loadKieModuleFromMavenRepo(KieRepositoryImpl.java:130)
at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.getKieModule(KieRepositoryImpl.java:116)
at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.getKieModule(KieRepositoryImpl.java:93)
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:115)
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:111)


After 1 or 2 weeks,getting below exception

22-Dec-2016 05:34:12.894 WARN [pool-13-thread-1] org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction HHH000326: Cannot join transaction: do not override hibernate.transaction.factory_class
[pool-13-thread-1] WARN org.jbpm.shared.services.impl.TransactionalCommandService - Could not commit session
javax.persistence.TransactionRequiredException: No active JTA transaction on joinTransaction call
at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1233)
at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1183)
at org.jbpm.shared.services.impl.JpaPersistenceContext.joinTransaction(JpaPersistenceContext.java:206)
at org.jbpm.shared.services.impl.TransactionalCommandService.execute(TransactionalCommandService.java:70)
at org.jbpm.kie.services.impl.store.DeploymentStore.getDeploymentUnitsByDate(DeploymentStore.java:112)
at org.jbpm.kie.services.impl.store.DeploymentSynchronizer.synchronize(DeploymentSynchronizer.java:86)
at org.jbpm.kie.services.impl.store.DeploymentSyncInvoker$TriggerDeploymentSync.run(DeploymentSyncInvoker.java:81)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[pool-13-thread-1] ERROR org.jbpm.kie.services.impl.store.DeploymentSynchronizer - Error while synchronizing deployments: No active JTA transaction on joinTransaction call
javax.persistence.TransactionRequiredException: No active JTA transaction on joinTransaction call
at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1233)
at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1183)
at org.jbpm.shared.services.impl.JpaPersistenceContext.joinTransaction(JpaPersistenceContext.java:206)
at org.jbpm.shared.services.impl.TransactionalCommandService.execute(TransactionalCommandService.java:70)
at org.jbpm.kie.services.impl.store.DeploymentStore.getDeploymentUnitsByDate(DeploymentStore.java:112)
at org.jbpm.kie.services.impl.store.DeploymentSynchronizer.synchronize(DeploymentSynchronizer.java:86)
at org.jbpm.kie.services.impl.store.DeploymentSyncInvoker$TriggerDeploymentSync.run(DeploymentSyncInvoker.java:81)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)


Thanks,
Subhash.



On Tuesday, December 27, 2016 at 4:42:12 PM UTC+5:30, Ruler wrote:

Edson Tirelli

unread,
Jan 6, 2017, 10:03:00 AM1/6/17
to drools...@googlegroups.com
 
   Am I misreading your log or did you name your jar LATEST? If so, I think you are misunderstanding how maven works. You should not name your jar "LATEST". Your jar should have an actual version number, but when you create a KieContainer with version "LATEST", maven will look for the latest jar version available. Please read on maven versioning here:



   If that is not the case, ignore me.

   If you want to re-check the maven repository for a new version of the jar (when setting the KieContainer version to LATEST), then you need to start a scanner. You can either set a polling interval (e.g., every minute, or every hour, or every day, etc) and the scanner will automatically check the maven repository, or your application code can call scanNow() to immediately check the repository. 

   In this case the KieContainer will automatically be updated if a new version is found. Please note that maven requires the actual jar version to be incremented, or that you use -SNAPSHOT sufix (which I don't really recommend for production). Just use a counter to increment the version of the jar every time you release... like "mykjar-1.0.35.jar", "mykjar-1.0.36.jar", etc.

   Here is an example of how to use the scanner:


   And last time I checked, KieContainer had a dispose() method: ;)


   Edson


--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage+unsubscribe@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages