eclipse - Drools can't find kjars referenced by the projects POM file -
i'm having hard time trying run spring boot application drools projects dependencies.
the project spring boot application , references 2 different drools projects. runs fine on eclipse, when try run using java -jar
, drools can't find 1 of 2 related projects.
i describe steps application doing , guesses problem source make easier follow.
step 1: during spring cdi, call kieservices retrieve 1 of defined kiebases:
kiecontainer kcontainer = kieservices.factory.get().getkieclasspathcontainer(); return kcontainer.getkiebase("kbase-common-rules");
the result of classpath search shown in 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 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 added: zipkiemodule[releaseid=br.com.credisfera:credisfera-services:3.3.0-snapshot,file=/home/credisfera-services/target/credisfera-services-3.3.0-snapshot.jar]
kie able create kiebase correctly, although believe strange in log. note kie "finds" modules inside projects jar (found kmodule messages), adds own project jar kie module (zipkiemodule messages). different when run using eclipse, inside eclipse individual jars added, never project jar.
step 2: again, spring cdi tries create kiebase:
kiecontainer kcontainer = kieservices.factory.get().getkieclasspathcontainer(); return kcontainer.getkiebase("kbase-cep");
this time, kie logs show nothing (as factory singleton), application fails:
factory method 'ksessioncep' threw exception; nested exception java.lang.runtimeexception: requested kiebase "kbase-cep" not exist
as can imagine, ksessioncep exists. try 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, works fine. so: project ok kie (at least maven scanner), can't find using classpath scanner.
i have 2 guesses right now:
- it's kie bug. kie shouldn't inserting spring boot jar twice kiemodule, , it's not able create more 1 kiecontainer internally;
- maybe there's classpath configuration allow kie add referenced projects kiemodules instead of parent jar?
i prefer not use explicit versions in source code , rely on maven keep managing dependencies, i'm not considering second approach solution far.
Comments
Post a Comment