Drools + spring-boot - does not load rules artifact from releaseId when using dependencyManager

2,081 views
Skip to first unread message

Gleidson Echeli

unread,
Feb 16, 2018, 11:45:27 AM2/16/18
to Drools Usage
Hello everyone, before talking about the problem I am having, I will first explain how we are using Drools:

We have a microservice application, which makes use of JHipster to make our lives easier. Our application is a Spring Boot application that uses Spring Cloud and etc. This application uses Drools and for this we have 2 separate artifacts: a pojos artifact - in the example, drools-problem-pojos, which contains the modeling of the classes used in the Drools rules and a rules artifact - in the example drools-problem-rules, which contains the Drools drl files and kmodule.xml.

So the application has as dependence on pom.xml, the pojos artifact - drools-problem-pojos - and kie-ci, besides other dependencies. The rules artifact - drools-problem-rules - are loaded at runtime through the ReleaseId, which fetches from maven.

Having said that, the following happens:

When pom.xml has normal dependencies, without using dependencyManager, the project works fine as expected. However when using a dependencyManager, like the spring-cloud-dependencies, the application does not even go up. The error below occurs. Has anyone ever had this problem? How did you solve it?
One solution that works is not to use dependencyManager and manually put the version of all the dependencies we use in the project. But this is unfeasible in projects with many dependencies, as is our case. I do not know what else to do.

To illustrate this, I uploaded a working example in my github - https://github.com/elgleidson/drools-problem

The only difference between them is the use of dependencyManager in pom.xml of drools-problema-main-error.

To rund, just do the following:

$ mvn clean install

====================================================================
Application log that works:

$ java -jar drools-problem-main/target/drools-problem-main-1.0.0.jar 

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::       (v1.5.10.RELEASE)

2018-02-16 13:43:27.401  INFO 13452 --- [           main] b.c.e.d.p.main.DroolsProblemApplication  : Starting DroolsProblemApplication v1.0.0 on cerberus with PID 13452 (/home/gleidson/projects/drools-problem/drools-problem-main/target/drools-problem-main-1.0.0.jar started by gleidson in /home/gleidson/projects/drools-problem)
2018-02-16 13:43:27.409 DEBUG 13452 --- [           main] b.c.e.d.p.main.DroolsProblemApplication  : Running with Spring Boot v1.5.10.RELEASE, Spring v4.3.14.RELEASE
2018-02-16 13:43:27.410  INFO 13452 --- [           main] b.c.e.d.p.main.DroolsProblemApplication  : No active profile set, falling back to default profiles: default
2018-02-16 13:43:30.013 DEBUG 13452 --- [           main] b.c.e.d.p.m.config.DroolsConfiguration   : getting ReleaseId br.com.effect4-drools-problem-rules:1.0.0...
2018-02-16 13:43:30.017 DEBUG 13452 --- [           main] b.c.e.d.p.m.config.DroolsConfiguration   : getting KieServices...
2018-02-16 13:43:30.056 DEBUG 13452 --- [           main] b.c.e.d.p.m.config.DroolsConfiguration   : KieServices
2018-02-16 13:43:30.064 DEBUG 13452 --- [           main] b.c.e.d.p.m.config.DroolsConfiguration   : ReleaseId got!
2018-02-16 13:43:30.065 DEBUG 13452 --- [           main] b.c.e.d.p.m.config.DroolsConfiguration   : getting KieContainer from releaseId...
2018-02-16 13:43:30.115  WARN 13452 --- [           main] o.a.m.i.embedder.MavenSettings           : Environment variable M2_HOME is not set
2018-02-16 13:43:35.364 DEBUG 13452 --- [           main] b.c.e.d.p.m.config.DroolsConfiguration   : KieContainer got!
2018-02-16 13:43:36.395  INFO 13452 --- [           main] b.c.e.d.p.main.DroolsProblemApplication  : Started DroolsProblemApplication in 9.562 seconds (JVM running for 10.196)


====================================================================

Application log that does not works:

$ java -jar drools-problem-main-error/target/drools-problem-main-error-1.0.0.jar 

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::       (v1.5.10.RELEASE)

2018-02-16 13:46:25.232  INFO 13607 --- [           main] b.c.e.d.p.main.DroolsProblemApplication  : Starting DroolsProblemApplication v1.0.0 on cerberus with PID 13607 (/home/gleidson/projects/drools-problem/drools-problem-main-error/target/drools-problem-main-error-1.0.0.jar started by gleidson in /home/gleidson/projects/drools-problem)
2018-02-16 13:46:25.238 DEBUG 13607 --- [           main] b.c.e.d.p.main.DroolsProblemApplication  : Running with Spring Boot v1.5.10.RELEASE, Spring v4.3.14.RELEASE
2018-02-16 13:46:25.238  INFO 13607 --- [           main] b.c.e.d.p.main.DroolsProblemApplication  : No active profile set, falling back to default profiles: default
2018-02-16 13:46:27.766 DEBUG 13607 --- [           main] b.c.e.d.p.m.config.DroolsConfiguration   : getting ReleaseId br.com.effect4-drools-problem-rules:1.0.0...
2018-02-16 13:46:27.770 DEBUG 13607 --- [           main] b.c.e.d.p.m.config.DroolsConfiguration   : getting KieServices...
2018-02-16 13:46:27.810 DEBUG 13607 --- [           main] b.c.e.d.p.m.config.DroolsConfiguration   : KieServices
2018-02-16 13:46:27.818 DEBUG 13607 --- [           main] b.c.e.d.p.m.config.DroolsConfiguration   : ReleaseId got!
2018-02-16 13:46:27.818 DEBUG 13607 --- [           main] b.c.e.d.p.m.config.DroolsConfiguration   : getting KieContainer from releaseId...
2018-02-16 13:46:27.864  WARN 13607 --- [           main] o.a.m.i.embedder.MavenSettings           : Environment variable M2_HOME is not set
2018-02-16 13:46:29.717  WARN 13607 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'droolsResource': Unsatisfied dependency expressed through field 'kieContainer'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getKieContainer' defined in class path resource [br/com/effect4/drools/problem/main/config/DroolsConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.kie.api.runtime.KieContainer]: Factory method 'getKieContainer' threw exception; nested exception is java.lang.NoSuchMethodError: com.thoughtworks.xstream.XStream.setupDefaultSecurity(Lcom/thoughtworks/xstream/XStream;)V
2018-02-16 13:46:29.756 ERROR 13607 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'droolsResource': Unsatisfied dependency expressed through field 'kieContainer'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getKieContainer' defined in class path resource [br/com/effect4/drools/problem/main/config/DroolsConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.kie.api.runtime.KieContainer]: Factory method 'getKieContainer' threw exception; nested exception is java.lang.NoSuchMethodError: com.thoughtworks.xstream.XStream.setupDefaultSecurity(Lcom/thoughtworks/xstream/XStream;)V
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE]
at br.com.effect4.drools.problem.main.DroolsProblemApplication.main(DroolsProblemApplication.java:10) [classes!/:1.0.0]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_162]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_162]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_162]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [drools-problem-main-error-1.0.0.jar:1.0.0]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [drools-problem-main-error-1.0.0.jar:1.0.0]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [drools-problem-main-error-1.0.0.jar:1.0.0]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [drools-problem-main-error-1.0.0.jar:1.0.0]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getKieContainer' defined in class path resource [br/com/effect4/drools/problem/main/config/DroolsConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.kie.api.runtime.KieContainer]: Factory method 'getKieContainer' threw exception; nested exception is java.lang.NoSuchMethodError: com.thoughtworks.xstream.XStream.setupDefaultSecurity(Lcom/thoughtworks/xstream/XStream;)V
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
... 27 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.kie.api.runtime.KieContainer]: Factory method 'getKieContainer' threw exception; nested exception is java.lang.NoSuchMethodError: com.thoughtworks.xstream.XStream.setupDefaultSecurity(Lcom/thoughtworks/xstream/XStream;)V
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
... 39 common frames omitted
Caused by: java.lang.NoSuchMethodError: com.thoughtworks.xstream.XStream.setupDefaultSecurity(Lcom/thoughtworks/xstream/XStream;)V
at org.kie.soup.commons.xstream.XStreamUtils.internalCreateTrustingXStream(XStreamUtils.java:168) ~[kie-soup-commons-7.5.0.Final.jar!/:7.5.0.Final]
at org.kie.soup.commons.xstream.XStreamUtils.createTrustingXStream(XStreamUtils.java:119) ~[kie-soup-commons-7.5.0.Final.jar!/:7.5.0.Final]
at org.drools.compiler.kproject.models.KieModuleModelImpl$kModuleMarshaller.<init>(KieModuleModelImpl.java:170) ~[drools-compiler-7.5.0.Final.jar!/:7.5.0.Final]
at org.drools.compiler.kproject.models.KieModuleModelImpl$kModuleMarshaller.<init>(KieModuleModelImpl.java:169) ~[drools-compiler-7.5.0.Final.jar!/:7.5.0.Final]
at org.drools.compiler.kproject.models.KieModuleModelImpl.<clinit>(KieModuleModelImpl.java:167) ~[drools-compiler-7.5.0.Final.jar!/:7.5.0.Final]
at org.kie.scanner.KieRepositoryScannerImpl.getKieModuleModelFromJar(KieRepositoryScannerImpl.java:231) ~[kie-ci-7.5.0.Final.jar!/:7.5.0.Final]
at org.kie.scanner.KieRepositoryScannerImpl.createZipKieModule(KieRepositoryScannerImpl.java:222) ~[kie-ci-7.5.0.Final.jar!/:7.5.0.Final]
at org.kie.scanner.KieRepositoryScannerImpl.buildArtifact(KieRepositoryScannerImpl.java:195) ~[kie-ci-7.5.0.Final.jar!/:7.5.0.Final]
at org.kie.scanner.KieRepositoryScannerImpl.loadArtifact(KieRepositoryScannerImpl.java:154) ~[kie-ci-7.5.0.Final.jar!/:7.5.0.Final]
at org.kie.scanner.KieRepositoryScannerImpl.loadArtifact(KieRepositoryScannerImpl.java:149) ~[kie-ci-7.5.0.Final.jar!/:7.5.0.Final]
at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.loadKieModuleFromMavenRepo(KieRepositoryImpl.java:192) ~[drools-compiler-7.5.0.Final.jar!/:7.5.0.Final]
at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.getKieModule(KieRepositoryImpl.java:138) ~[drools-compiler-7.5.0.Final.jar!/:7.5.0.Final]
at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.getKieModule(KieRepositoryImpl.java:115) ~[drools-compiler-7.5.0.Final.jar!/:7.5.0.Final]
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:184) ~[drools-compiler-7.5.0.Final.jar!/:7.5.0.Final]
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:172) ~[drools-compiler-7.5.0.Final.jar!/:7.5.0.Final]
at br.com.effect4.drools.problem.main.config.DroolsConfiguration.getKieContainer(DroolsConfiguration.java:35) ~[classes!/:1.0.0]
at br.com.effect4.drools.problem.main.config.DroolsConfiguration$$EnhancerBySpringCGLIB$$489092e1.CGLIB$getKieContainer$1(<generated>) ~[classes!/:1.0.0]
at br.com.effect4.drools.problem.main.config.DroolsConfiguration$$EnhancerBySpringCGLIB$$489092e1$$FastClassBySpringCGLIB$$817b7461.invoke(<generated>) ~[classes!/:1.0.0]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at br.com.effect4.drools.problem.main.config.DroolsConfiguration$$EnhancerBySpringCGLIB$$489092e1.getKieContainer(<generated>) ~[classes!/:1.0.0]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_162]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_162]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_162]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
... 40 common frames omitted

Reply all
Reply to author
Forward
0 new messages