Note: I added this same question in StackOverflow last week but got no answer/comment for a few days, so I'm trying here.
Drools 6.5 / Spring Boot 1.3.3
I'm having a hard time trying to run a Spring Boot application with Drools projects dependencies. The project is a Spring Boot application and references 2 different Drools projects. Everything runs fine on Eclipse, but when I try to run using java -jar, Drools can't find 1 of the 2 related projects.
I will describe the steps the application is doing and my guesses about the problem source to make it easier to follow.
Step 1: during Spring CDI, I call KieServices to retrieve 1 of the defined KieBases:
KieContainer kcontainer = KieServices.Factory.get().getKieClasspathContainer();
return kcontainer.getKieBase("kbase-common-rules");
The result of this classpath search is shown in the logs:
ClasspathKieProject:131 : Found kmodule: jar:file:/home/credisfera-services/target/credisfera-services-3.3.0-SNAPSHOT.jar!/lib/credisfera-cep-1.0.1.jar!/META-INF/kmodule.xml
KieRepositoryImpl:113 : KieModule was added: ZipKieModule[releaseId=br.com.credisfera:credisfera-services:3.3.0-SNAPSHOT,file=/home/credisfera-services/target/credisfera-services-3.3.0-SNAPSHOT.jar]
ClasspathKieProject:131 : Found kmodule: jar:file:/home/credisfera-services/target/credisfera-services-3.3.0-SNAPSHOT.jar!/lib/common-rules-2.9.0.jar!/META-INF/kmodule.xml
KieRepositoryImpl:113 : KieModule was added: ZipKieModule[releaseId=br.com.credisfera:credisfera-services:3.3.0-SNAPSHOT,file=/home/credisfera-services/target/credisfera-services-3.3.0-SNAPSHOT.jar]Step 2: the application tries to create a KieBase from the first "found" JAR:
KieContainer kcontainer = KieServices.Factory.get().getKieClasspathContainer();
return kcontainer.getKieBase("kbase-cep");This time, Kie logs show nothing (as the Factory is a Singleton), but the application fails:
Factory method 'ksessionCep' threw exception; nested exception is java.lang.RuntimeException: The requested KieBase "kbase-cep" does not existAs you can imagine, ksessionCep exists. So I try a different approach:
final String groupId = "br.com.credisfera";
final String artifactId = "credisfera-cep";
final String version = "1.0.1";
final String kieBaseName = "kbase-cep";
final KieServices kieServices = KieServices.Factory.get();
final ReleaseId releaseId = kieServices.newReleaseId(groupId, artifactId, version);
final KieContainer kieContainer = kieServices.newKieContainer(releaseId);
final KieBase kieBase = (kieBaseName != null && !kieBaseName.isEmpty()) ? kieContainer.getKieBase(kieBaseName)
: kieContainer.getKieBase();
return kieContainer.newKieSession("ksession-cep");
This time, everything works fine. I conclude: the project is OK to Kie (at least for Maven scanner), but it can't find it using the classpath scanner.
I have 2 guesses right now:
I would prefer to not use explicit versions in the source code and rely completely on Maven to keep managing dependencies, so I'm not considering my second approach as a solution so far.
--
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/853cded7-8de0-4fe6-bc8f-94e73b905f65%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layout>ZIP</layout>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
--
You received this message because you are subscribed to a topic in the Google Groups "Drools Usage" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/drools-usage/odQjmBess5A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to drools-usage+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/dcb6a7df-a637-4873-bc0f-72e32a7617ea%40googlegroups.com.
KimJohn Quinn
k...@logicdrop.com
Logicdrop
22620 Woodward Avenue - Suite D
Ferndale, MI 48220
O 888.229.2817
M 248.882.0728
www.logicdrop.com
To unsubscribe from this group and all its topics, send an email to drools-usage...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/dcb6a7df-a637-4873-bc0f-72e32a7617ea%40googlegroups.com.
--KimJohn Quinn
k...@logicdrop.comLogicdrop
22620 Woodward Avenue - Suite D
Ferndale, MI 48220
O 888.229.2817
M 248.882.0728
www.logicdrop.com
--
You received this message because you are subscribed to a topic in the Google Groups "Drools Usage" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/drools-usage/odQjmBess5A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to drools-usage...@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/CAF1TLv4zJJHwPqegcAXd493gZpMnvcec625_BKEOc3d4uEecDQ%40mail.gmail.com.
To unsubscribe from this group and all its topics, send an email to drools-usage+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/dcb6a7df-a637-4873-bc0f-72e32a7617ea%40googlegroups.com.
----KimJohn Quinn
k...@logicdrop.comLogicdrop
22620 Woodward Avenue - Suite D
Ferndale, MI 48220
O 888.229.2817
M 248.882.0728
www.logicdrop.com
You received this message because you are subscribed to a topic in the Google Groups "Drools Usage" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/drools-usage/odQjmBess5A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to drools-usage+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/CAF1TLv4zJJHwPqegcAXd493gZpMnvcec625_BKEOc3d4uEecDQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Drools Usage" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/drools-usage/odQjmBess5A/unsubscribe.
To unsubscribe from this group and all its topics, 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/CAGaRV4RfjDSOQQ0jmMVBo9UaOpNEtgEpZypboq2%3DkAWcjpXmLQ%40mail.gmail.com.
final KieContainer kContainer = this.kServices.newKieContainer(containerKey, releaseId);
final KieContainer kContainer = this.kServices.newKieClasspathContainer();
[INFO ] org.drools.compiler.kie.builder.impl.ClasspathKieProject - Found kmodule: jar:file:/project/server/bin/my-server-2.3.0.0-SNAPSHOT.jar!/BOOT-INF/lib/my-rules-2.3.0.0-SNAPSHOT.jar!/META-INF/kmodule.xml
[INFO ] org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: ZipKieModule[releaseId=com.my-server:2.3.0.0-SNAPSHOT,file=/project/server/bin/my-server-2.3.0.0-SNAPSHOT.jar]
[DEBUG] drools.services.DroolsContainerFactory - Created container rules (com.my-server:my-rules:2.3.0.0-SNAPSHOT)
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<requiresUnpack>
<dependency>
<groupId>com.sample</groupId>
<artifactId>kproject1</artifactId>
</dependency>
<dependency>
<groupId>com.sample</groupId>
<artifactId>kproject2</artifactId>
</dependency>
</requiresUnpack>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
--
You received this message because you are subscribed to a topic in the Google Groups "Drools Usage" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/drools-usage/odQjmBess5A/unsubscribe.
To unsubscribe from this group and all its topics, 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/a3116aa6-4914-4772-be79-6295659201a1%40googlegroups.com.
To unsubscribe from this group and all its topics, send an email to drools-usage...@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/a3116aa6-4914-4772-be79-6295659201a1%40googlegroups.com.
--KimJohn Quinn
k...@logicdrop.comLogicdrop
22620 Woodward Avenue - Suite D
Ferndale, MI 48220
O 888.229.2817
M 248.882.0728
www.logicdrop.com
--
You received this message because you are subscribed to a topic in the Google Groups "Drools Usage" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/drools-usage/odQjmBess5A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to drools-usage...@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/CAF1TLv6Hm_4eAWSOzeKZuHTA7EvShf0kfESVVxCSVk8-T8qRAA%40mail.gmail.com.
To unsubscribe from this group and all its topics, send an email to drools-usage...@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/a3116aa6-4914-4772-be79-6295659201a1%40googlegroups.com.