I've seen in other questions that usually the solution to this warning is to exclude slf4j from the dependency that causes this conflict, but I can't spot the problem in my project.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/5/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/5/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
I run mvn dependency:tree command and this is the output:
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # subscriptionsmanager ---
[INFO] it.pietro:subscriptionsmanager:jar:0.0.1-SNAPSHOT
[INFO] +- junit:junit:jar:4.13.1:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.mockito:mockito-core:jar:3.5.13:test
[INFO] | +- net.bytebuddy:byte-buddy:jar:1.10.15:test
[INFO] | +- net.bytebuddy:byte-buddy-agent:jar:1.10.15:test
[INFO] | \- org.objenesis:objenesis:jar:3.1:test
[INFO] +- org.mongodb:mongo-java-driver:jar:3.12.7:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] | +- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- de.bwaldvogel:mongo-java-server:jar:1.11.1:compile
[INFO] | +- de.bwaldvogel:mongo-java-server-core:jar:1.11.1:compile
[INFO] | | +- io.netty:netty-transport:jar:4.1.31.Final:compile
[INFO] | | | +- io.netty:netty-buffer:jar:4.1.31.Final:compile
[INFO] | | | | \- io.netty:netty-common:jar:4.1.31.Final:compile
[INFO] | | | \- io.netty:netty-resolver:jar:4.1.31.Final:compile
[INFO] | | \- io.netty:netty-codec:jar:4.1.31.Final:compile
[INFO] | \- de.bwaldvogel:mongo-java-server-memory-backend:jar:1.11.1:compile
[INFO] +- org.assertj:assertj-core:jar:3.15.0:test
[INFO] +- org.testcontainers:mongodb:jar:1.15.1:compile
[INFO] | \- org.testcontainers:testcontainers:jar:1.15.1:compile
[INFO] | +- org.apache.commons:commons-compress:jar:1.20:compile
[INFO] | +- org.rnorth.duct-tape:duct-tape:jar:1.0.8:compile
[INFO] | +- org.rnorth.visible-assertions:visible-assertions:jar:2.1.2:compile
[INFO] | | \- net.java.dev.jna:jna:jar:5.2.0:compile
[INFO] | +- com.github.docker-java:docker-java-api:jar:3.2.7:compile
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.10.3:compile
[INFO] | \- com.github.docker-java:docker-java-transport-zerodep:jar:3.2.7:compile
[INFO] | \- com.github.docker-java:docker-java-transport:jar:3.2.7:compile
[INFO] +- org.assertj:assertj-swing-junit:jar:3.17.1:test
[INFO] | +- org.assertj:assertj-swing:jar:3.17.1:test
[INFO] | | \- org.easytesting:fest-util:jar:1.2.5:test
[INFO] | \- org.easytesting:fest-reflect:jar:1.4.1:test
[INFO] \- info.picocli:picocli:jar:4.5.2:compile
The SLF4J bindings warning comes from the Eclipse IDE itself and is not related to your application you write in the Eclipse IDE. So it's just noise that can be ignored (see e.g. here and here).
I guess you have the Eclipse IDE for Enterprise Java Developers with maybe some additional plugins installed. That's more than 900 JARs. SLF4J is used by the Maven support for Eclipse (in the SLF4J bindings warning as m2e) and also by at least one other plugin in an incompatible way causing this warnings. Eclipse is based on OSGi where there is not a flat classpath and where plugins/bundles can be installed, started, stopped and uninstalled at runtime. SLF4J seems not to build with OSGi in mind, hence the misleading warning Class path contains multiple SLF4J bindings, although there is no classpath in OSGi which uses its own class loader instead.
You can solve the issue by adding the following exclusion in the dependencies (of pom.xml) that caused conflict.
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
Related
We have an old drools library that've been upgrading to later versions of KIE, and Executable rule models caught my eye. When I started my migration, my dependencies looked like this:
<dependencies>
...
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.mvel</groupId>
<artifactId>mvel2</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>${kie.version}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-ci</artifactId>
<version>${kie.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
...
<plugin>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
<version>${kie.version}</version>
<extensions>true</extensions>
</plugin>
Using 7.26.0.Final. When I upgraded to 7.59.0.Final I added the compiler dependency as I was supposed to from the doc:
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-model-compiler</artifactId>
<version>${kie.version}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>${kie.version}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-ci</artifactId>
<version>${kie.version}</version>
</dependency>
But my generate model now seems to fail:
[INFO] --- kie-maven-plugin:7.59.0.Final:generateModel (default-generateModel) # rules ---
[INFO] Using NEW implementation
[INFO] Using NEW implementation
[INFO] Artifact not fetched from maven: org.drools:drools-model-compiler:7.59.0.Final. To enable the KieScanner you need kie-ci on the classpath
[INFO] Artifact not fetched from maven: org.kie:kie-ci:7.59.0.Final. To enable the KieScanner you need kie-ci on the classpath
[INFO] Artifact not fetched from maven: org.apache.commons:commons-collections4:4.4. To enable the KieScanner you need kie-ci on the classpath
[INFO] Artifact not fetched from maven: org.apache.commons:commons-lang3:3.12.0. To enable the KieScanner you need kie-ci on the classpath
[INFO] Artifact not fetched from maven: org.kie:kie-api:7.59.0.Final. To enable the KieScanner you need kie-ci on the classpath
[INFO] Artifact not fetched from maven: org.mvel:mvel2:2.4.12.Final. To enable the KieScanner you need kie-ci on the classpath
WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[ERROR] Unable to build KieBaseModel:plan-rules
InvalidExpressionErrorResult: Method equalsAnyIgnoreCase on class org.apache.commons.lang3.StringUtils with arguments [class java.lang.String, class java.lang.Object] is missing
InvalidExpressionErrorResult: Method intersectionsStartsWith on class com.accolade.clinical.utils.RuleUtils with arguments [interface java.util.List, class java.lang.Object] is missing
InvalidExpressionErrorResult: Method size on class java.lang.Object with arguments [] is missing
... (A lot more errors of this nature)
Why won't it pick up the dependencies even if I have maven CI and the plugin configured? Is there something I missed in the docs?
Edit:
As per the the first answer:
I tried replacing the 3 dependencies I've listed above with
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-engine</artifactId>
<version>${kie.version}</version>
</dependency>
But unfortunately kie doesn't want to use the new generate models method in this case:
[INFO] --- kie-maven-plugin:7.59.0.Final:generateModel (default-generateModel) # rules ---
[WARNING] You're trying to build rule assets in a project from an executable rule model, but you did not provide the required dependency on the project classpath.
To enable executable rule models for your project, add the `drools-model-compiler` dependency in the `pom.xml` file of your project.
[INFO]
[INFO] --- kie-maven-plugin:7.59.0.Final:generateDMNModel (default-generateDMNModel) # rules ---
[INFO]
[INFO] --- kie-maven-plugin:7.59.0.Final:generatePMMLModel (default-generatePMMLModel) # rules ---
[WARNING] Skipping `generatePMMLModel` because you did not provide the required dependency on the project classpath.
To enable it for your project, add the `drools-model-compiler` dependency in the `pom.xml` file of your project.
[INFO]
[INFO] --- kie-maven-plugin:7.59.0.Final:generateANC (default-generateANC) # rules ---
[INFO]
[INFO] --- kie-maven-plugin:7.59.0.Final:build (default-build) # rules ---
Here's an output of mvn dependency:tree:
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< com.mycompany:rules >---------------------
[INFO] Building Rules 5.0.0-SNAPSHOT
[INFO] --------------------------------[ kjar ]--------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # rules ---
[INFO] com.mycompany:rules:kjar:5.0.0-SNAPSHOT
[INFO] +- com.mycompany.acp.utilities:model-utilities:jar:7.1.0:compile
[INFO] | +- com.mycompany.acp.fhir:common-fhir:jar:8.2.0:compile
[INFO] | | +- io.swagger.core.v3:swagger-annotations:jar:2.1.10:compile
[INFO] | | +- io.swagger:swagger-annotations:jar:1.6.2:compile
[INFO] | | +- org.reflections:reflections:jar:0.9.12:compile
[INFO] | | | \- org.javassist:javassist:jar:3.26.0-GA:compile
[INFO] | | +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
[INFO] | | | \- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] | | +- commons-beanutils:commons-beanutils:jar:1.9.4:compile
[INFO] | | | +- commons-logging:commons-logging:jar:1.2:compile
[INFO] | | | \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] | | \- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] | +- com.github.java-json-tools:json-patch:jar:1.13:compile
[INFO] | +- com.github.java-json-tools:msg-simple:jar:1.2:compile
[INFO] | | \- com.github.java-json-tools:btf:jar:1.3:compile
[INFO] | +- com.github.java-json-tools:jackson-coreutils:jar:2.0:compile
[INFO] | +- com.contentful.java:java-sdk:jar:10.4.5:compile
[INFO] | | +- com.squareup.retrofit2:retrofit:jar:2.5.0:compile
[INFO] | | +- com.squareup.retrofit2:adapter-rxjava2:jar:2.5.0:compile
[INFO] | | +- com.squareup.retrofit2:converter-gson:jar:2.5.0:compile
[INFO] | | +- io.reactivex.rxjava2:rxjava:jar:2.2.6:compile
[INFO] | | | \- org.reactivestreams:reactive-streams:jar:1.0.2:compile
[INFO] | | +- com.squareup.okhttp3:okhttp:jar:3.12.12:compile
[INFO] | | | \- com.squareup.okio:okio:jar:1.15.0:compile
[INFO] | | +- com.google.code.gson:gson:jar:2.8.5:compile
[INFO] | | \- com.github.tony19:named-regexp:jar:0.2.5:compile
[INFO] | +- com.mycompany.acp.resources:singularity-models:jar:6.1.0:compile
[INFO] | | +- com.mycompany.acp-common-eventbus:models:jar:5.0.3:compile
[INFO] | | | \- com.amazonaws:aws-java-sdk-sns:jar:1.11.625:compile
[INFO] | | | \- com.amazonaws:aws-java-sdk-sqs:jar:1.11.625:compile
[INFO] | | +- com.amazonaws:aws-java-sdk-dynamodb:jar:1.12.18:compile
[INFO] | | | +- com.amazonaws:aws-java-sdk-s3:jar:1.12.18:compile
[INFO] | | | | \- com.amazonaws:aws-java-sdk-kms:jar:1.12.18:compile
[INFO] | | | +- com.amazonaws:aws-java-sdk-core:jar:1.12.18:compile
[INFO] | | | | +- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
[INFO] | | | | | \- org.apache.httpcomponents:httpcore:jar:4.4.13:compile
[INFO] | | | | +- software.amazon.ion:ion-java:jar:1.0.2:compile
[INFO] | | | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.12.3:compile
[INFO] | | | | \- joda-time:joda-time:jar:2.8.1:compile
[INFO] | | | \- com.amazonaws:jmespath-java:jar:1.12.18:compile
[INFO] | | +- com.amazonaws:aws-java-sdk-sts:jar:1.12.18:compile
[INFO] | | \- com.mycompany.acp.fhir:common-utilities:jar:8.2.0:compile
[INFO] | | \- org.springframework:spring-web:jar:5.3.8:compile
[INFO] | | +- org.springframework:spring-beans:jar:5.3.8:compile
[INFO] | | \- org.springframework:spring-core:jar:5.3.8:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.3.8:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-databind:jar:2.12.4:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.12.4:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.12.4:compile
[INFO] +- org.apache.commons:commons-collections4:jar:4.4:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.12.0:compile
[INFO] +- commons-io:commons-io:jar:2.11.0:compile
[INFO] +- org.mvel:mvel2:jar:2.4.12.Final:compile
[INFO] +- org.slf4j:slf4j-api:jar:2.0.0-alpha5:provided
[INFO] +- org.projectlombok:lombok:jar:1.18.20:provided
[INFO] +- org.drools:drools-engine:jar:7.59.0.Final:compile
[INFO] | +- org.kie:kie-api:jar:7.59.0.Final:compile
[INFO] | | \- org.kie.soup:kie-soup-maven-support:jar:7.59.0.Final:compile
[INFO] | +- org.kie:kie-internal:jar:7.59.0.Final:compile
[INFO] | +- org.drools:drools-core:jar:7.59.0.Final:compile
[INFO] | | +- org.kie.soup:kie-soup-xstream:jar:7.59.0.Final:compile
[INFO] | | +- org.drools:drools-core-reflective:jar:7.59.0.Final:compile
[INFO] | | +- org.drools:drools-core-dynamic:jar:7.59.0.Final:runtime
[INFO] | | \- commons-codec:commons-codec:jar:1.11:compile
[INFO] | +- org.drools:drools-compiler:jar:7.59.0.Final:compile
[INFO] | | +- org.kie:kie-memory-compiler:jar:7.59.0.Final:compile
[INFO] | | +- org.drools:drools-ecj:jar:7.59.0.Final:compile
[INFO] | | +- org.antlr:antlr-runtime:jar:3.5.2:compile
[INFO] | | \- com.thoughtworks.xstream:xstream:jar:1.4.17:compile
[INFO] | | \- io.github.x-stream:mxparser:jar:1.2.1:compile
[INFO] | | \- xmlpull:xmlpull:jar:1.1.3.1:compile
[INFO] | \- org.drools:drools-model-compiler:jar:7.59.0.Final:compile
[INFO] | +- org.drools:drools-canonical-model:jar:7.59.0.Final:compile
[INFO] | +- com.github.javaparser:javaparser-core:jar:3.13.10:compile
[INFO] | +- org.drools:drools-mvel-parser:jar:7.59.0.Final:compile
[INFO] | \- org.drools:drools-mvel-compiler:jar:7.59.0.Final:compile
[INFO] +- xerces:xercesImpl:jar:2.12.1:test
[INFO] | \- xml-apis:xml-apis:jar:1.4.01:test
[INFO] +- com.google.guava:guava:jar:30.1.1-jre:test
[INFO] | +- com.google.guava:failureaccess:jar:1.0.1:test
[INFO] | +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:test
[INFO] | +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] | +- org.checkerframework:checker-qual:jar:3.8.0:test
[INFO] | +- com.google.errorprone:error_prone_annotations:jar:2.5.1:test
[INFO] | \- com.google.j2objc:j2objc-annotations:jar:1.3:test
[INFO] +- org.junit.jupiter:junit-jupiter-api:jar:5.7.2:test
[INFO] | +- org.apiguardian:apiguardian-api:jar:1.1.0:test
[INFO] | +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] | \- org.junit.platform:junit-platform-commons:jar:1.7.2:test
[INFO] +- org.junit.jupiter:junit-jupiter-engine:jar:5.7.2:test
[INFO] | \- org.junit.platform:junit-platform-engine:jar:1.7.2:test
[INFO] \- org.junit.jupiter:junit-jupiter-params:jar:5.7.2:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.439 s
[INFO] Finished at: 2021-09-19T23:53:58-07:00
[INFO] ------------------------------------------------------------------------
Can you try using these new wrapper modules? They should solve your problem
"
This issue is mainly caused by the fact that users have among their dependencies modules like drools-core and drools-compiler that in reality are no more than "internal implementation details". To avoid similar problems in future, in the very likely case that other modules will be introduced to split engine in finer grained submodules and descope optional features, the following 2 new wrapper modules have been created to cover the 2 different main usage scenarios:
drools-engine aggregating drools-core, drools-compiler and drools-model-compiler
drools-engine-classic aggregating drools-core, drools-compiler and drools-mvel
"
If you want to use the executable model, use drools-engine
Edit:
The dependencies are correct, if you see this error message
InvalidExpressionErrorResult: Method equalsAnyIgnoreCase on class org.apache.commons.lang3.StringUtils with arguments [class java.lang.String, class java.lang.Object] is missing
InvalidExpressionErrorResult: Method intersectionsStartsWith on class com.accolade.clinical.utils.RuleUtils with arguments [interface java.util.List, class java.lang.Object] is missing
InvalidExpressionErrorResult: Method size on class java.lang.Object with arguments [] is missing
It means the executable model is compiling, but it's failing on some of your rules. We'll need a reproducer to see what's going on now. For example the line
InvalidExpressionErrorResult: Method size on class java.lang.Object with arguments [] is missing
Seems really strange as Object doesn't have a size() method.
Please file a bug on issues.redhat.com uploading your obfuscated rules so that we can investigate further.
I am having some difficulty configuring some loggers for velocity in Spring. I am using Velocity 2.1, Spring 5.2.2 and SLF4J 2.0.0
org.slf4j.simple.SimpleLogger object set as runtime.log.instance is not a valid org.slf4j.Logger implementation.
I am trying to configure some old discarded Spring classes to build a JAR (new versions of them) to use in my application.
velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_INSTANCE, (new SimpleLoggerFactory()).getLogger("SpringVelocityConfiguration"));
This is how I am doing it. But I keep getting the exception.
The line throwing the exception is from org.apache.velocity.runtime.RuntimeInstance:
if (Logger.class.isAssignableFrom(o.getClass()))
From what I saw from the API documentation, SimpleLogger is a subclass to Logger. So it should work out isn't it?
Adding the dependency tree as requested:
[INFO] --- maven-dependency-plugin:3.1.1:tree (default-cli) # spring-velocity-support ---
[INFO] com.gtt.palabs:spring-velocity-support:jar:0.0.1-SNAPSHOT
[INFO] +- commons-logging:commons-logging:jar:1.2:provided
[INFO] +- javax.servlet:javax.servlet-api:jar:4.0.1:provided
[INFO] +- org.slf4j:slf4j-api:jar:2.0.0-alpha1:provided
[INFO] +- org.slf4j:slf4j-simple:jar:2.0.0-alpha1:compile
[INFO] +- org.springframework:spring-context:jar:5.2.2.RELEASE:provided
[INFO] | +- org.springframework:spring-aop:jar:5.2.2.RELEASE:provided
[INFO] | +- org.springframework:spring-beans:jar:5.2.2.RELEASE:provided
[INFO] | \- org.springframework:spring-expression:jar:5.2.2.RELEASE:provided
[INFO] +- org.springframework:spring-core:jar:5.2.2.RELEASE:provided
[INFO] | \- org.springframework:spring-jcl:jar:5.2.2.RELEASE:provided
[INFO] +- org.springframework:spring-web:jar:5.2.2.RELEASE:provided
[INFO] +- org.springframework:spring-webmvc:jar:5.2.2.RELEASE:provided
[INFO] +- org.apache.velocity:velocity-engine-core:jar:2.1:provided
[INFO] | \- org.apache.commons:commons-lang3:jar:3.9:compile
[INFO] +- org.apache.velocity.tools:velocity-tools-generic:jar:3.0:provided
[INFO] | +- commons-beanutils:commons-beanutils:jar:1.9.3:compile
[INFO] | | \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] | +- org.apache.commons:commons-digester3:jar:3.2:compile
[INFO] | | \- cglib:cglib:jar:2.2.2:compile
[INFO] | | \- asm:asm:jar:3.3.1:compile
[INFO] | \- com.github.cliftonlabs:json-simple:jar:3.0.2:provided
[INFO] \- org.apache.velocity.tools:velocity-tools-view:jar:3.0:compile
Error:
org.apache.velocity.exception.VelocityException: Error initializing log: com.gtt.logicalprovisioning.velocity.utilities.VelocityLogger object set as runtime.log.instance is not a valid org.slf4j.Logger implementation.
at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:958)
at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:260)
at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:90)
at com.gtt.logicalprovisioning.velocity.utilities.VelocityBuilderSystem.<init>(VelocityBuilderSystem.java:69)
at com.gtt.logicalprovisioning.ipflex.VelocityBuilderAction.processAction(VelocityBuilderAction.java:158)
at com.gtt.logicalprovisioning.rtp.BaseActionListType.run(BaseActionListType.java:72)
Caused by: org.apache.velocity.exception.VelocityException: com.gtt.logicalprovisioning.velocity.utilities.VelocityLogger object set as runtime.log.instance is not a valid org.slf4j.Logger implementation.
at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:931)
... 5 more
The log line says it all:
org.apache.velocity.exception.VelocityException: Error initializing log:
com.gtt.logicalprovisioning.velocity.utilities.VelocityLogger
object set as runtime.log.instance
is not a valid org.slf4j.Logger implementation.
It means that the old Spring classes you are working with do overwrite the runtime.instance.log property before Velocity initialization is carried on.
In my project I have a package that uses several 3rd party libraries. Let's have a look at the dependency tree:
[INFO] +- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- org.apache.directory.studio:org.apache.commons.collections:jar:3.2.1:compile
[INFO] | \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] +- xerces:xercesImpl:jar:2.11.0:compile
[INFO] | \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] +- org.apache.cxf:cxf-rt-bindings-soap:jar:3.2.2:compile
[INFO] | +- org.apache.cxf:cxf-core:jar:3.2.2:compile
[INFO] | | +- com.fasterxml.woodstox:woodstox-core:jar:5.0.3:compile
[INFO] | | | \- org.codehaus.woodstox:stax2-api:jar:3.1.4:compile
[INFO] | | \- org.apache.ws.xmlschema:xmlschema-core:jar:2.2.3:compile
[INFO] | +- org.apache.cxf:cxf-rt-wsdl:jar:3.2.2:compile
[INFO] | | +- wsdl4j:wsdl4j:jar:1.6.3:compile
[INFO] | | \- org.ow2.asm:asm:jar:5.2:compile
[INFO] | \- org.apache.cxf:cxf-rt-databinding-jaxb:jar:3.2.2:compile
[INFO] +- org.apache.wss4j:wss4j-ws-security-common:jar:2.2.1:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.22:compile
[INFO] | +- org.apache.santuario:xmlsec:jar:2.1.1:compile
[INFO] | | \- commons-codec:commons-codec:jar:1.10:compile
[INFO] | +- org.opensaml:opensaml-saml-impl:jar:3.3.0:compile
[INFO] | | +- org.opensaml:opensaml-profile-api:jar:3.3.0:compile
[INFO] | | | \- org.opensaml:opensaml-core:jar:3.3.0:compile
[INFO] | | | \- io.dropwizard.metrics:metrics-core:jar:3.1.2:compile
[INFO] | | +- org.opensaml:opensaml-saml-api:jar:3.3.0:compile
[INFO] | | | +- org.opensaml:opensaml-xmlsec-api:jar:3.3.0:compile
[INFO] | | | \- org.opensaml:opensaml-soap-api:jar:3.3.0:compile
[INFO] | | +- org.opensaml:opensaml-security-impl:jar:3.3.0:compile
[INFO] | | | \- org.opensaml:opensaml-security-api:jar:3.3.0:compile
[INFO] | | | +- org.cryptacular:cryptacular:jar:1.1.1:compile
[INFO] | | | \- org.bouncycastle:bcprov-jdk15on:jar:1.55:compile
[INFO] | | +- org.opensaml:opensaml-xmlsec-impl:jar:3.3.0:compile
[INFO] | | \- net.shibboleth.utilities:java-support:jar:7.3.0:compile
[INFO] | | +- com.google.guava:guava:jar:19.0:compile
[INFO] | | \- joda-time:joda-time:jar:2.7:compile
[INFO] | +- org.opensaml:opensaml-xacml-impl:jar:3.3.0:compile
[INFO] | | \- org.opensaml:opensaml-xacml-api:jar:3.3.0:compile
[INFO] | +- org.opensaml:opensaml-xacml-saml-impl:jar:3.3.0:compile
[INFO] | | \- org.opensaml:opensaml-xacml-saml-api:jar:3.3.0:compile
[INFO] | +- org.jasypt:jasypt:jar:1.9.2:compile
[INFO] | \- org.apache.geronimo.javamail:geronimo-javamail_1.4_mail:jar:1.8.4:compile
[INFO] +- org.apache.wss4j:wss4j-ws-security-dom:jar:2.2.1:compile
[INFO] | \- net.sf.ehcache:ehcache:jar:2.10.4:runtime
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.22:compile
[INFO] +- log4j:log4j:jar:1.2.17:compile
[INFO] \- org.testng:testng:jar:6.11:test
[INFO] +- com.beust:jcommander:jar:1.64:test
[INFO] \- org.yaml:snakeyaml:jar:1.17:test
Compiling and running works fine so far.
But when I what to start debugging with IntelliJ, I get a list of over 100 errors like:
Error:java: the unnamed module reads package org.opensaml.saml.config from both opensaml.saml.api and opensaml.saml.impl
Error:java: the unnamed module reads package javax.xml.datatype from both xml.apis and java.xml
Error:java: the unnamed module reads package javax.xml.transform.dom from both xml.apis and java.xml
....
This seems to be an error due to the new Java 9 module restrictions. But how to deal with here?
Both org.opensaml are part of wss4j-ws-security-common 2.2.1 (this is the last version, released in January 2018). opensaml.saml.api and opensaml.saml.impl are version 3.3.0 and both use org.opensaml.saml.config of the same version. So???
And why does "mvn compile" pass, but debugging with IntelliJ fails?
I had the same 100+ multititude of "ERROR: The unnamed module reads package javax.xml from both xml.apis and java.xml" in my Java 9 IntelliJ project too.
Except I would get them whenever I tried to run unit tests in IntelliJ. Everything worked perfectly building and testing with maven from the command line; just like you.
I was able to make my errors go away by...
1) Removing the following from the top-level pom of a multi-module project...
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
...
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>${javaee.api.version}</version>
<scope>provided</scope>
</dependency>
2) Right clicking the top-level pom in IntelliJ's project navigator, then select "Maven - Reimport"
3) Doing "Build -> Build module [myModule]" from the IntelliJ menu.
Just work out which maven artifacts contain the packages listed in your 100+"ERROR" messages. Then comment them out. Reimport. Then "Build module" from the menu. That worked for me anyway.
The artifacts I removed from the pom were copy/pasted in there speculatively from another project I used as a template. But luckily I don't need any of them.
This is a known IDEA bug. Please vote for https://youtrack.jetbrains.com/issue/IDEA-171320
I am trying to enable printing debugging information for a maven project. I added log4j as dependency to pom.xml and added log4j.properties as well as log4j2.properties with rootloger=DEBUG, sdout to src/main/resources folder. Then in the desired class, I initiate a logger in the desired class 'org.pakage1.ClassA' and add logger.debug() lines but nothing was shown in my consul. When I checked logger.isDebugEnabled() it returns false
pom.xml
<dependencies>
.....
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.25</version>
</dependency>
log4j.properties and similarly log4j2
log4j.debug=true
log4j.rootLogger=DEBUG, stdout
log4j.appender.Stdout.threshold=debug
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%-5p %d [%t] %c{1} - %m%n
and as extra step I tried adding
log4j.logger.extendedsldnf.ExtendedSLDNFEvaluator=DEBUG
but it also did not work.
package package1;
......
class ClassA{
private Logger logger = LoggerFactory.getLogger(getClass());
......
public static void main(String []args){
logger.debug("message");
}
}
Knowing that I am getting warning
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
Also the project has other sub-modules that also have logging enabled similarly and debugging messages works well when stated in the log4j.properties file
Is there something missing? How to check if there is something conflicting?
added log4j.properties as well as log4j2.properties
The first one is for log4j 1, the second one is for log4j 2.
Declaring both is not a way to solve your problem.
Use only which one that matches to your actual log4j version.
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Actual
binding is of type
[ch.qos.logback.classic.util.ContextSelectorStaticBinder]
Indeed, the problem is rather clear : you want to use the log4J implementation as SLF4J binding but you have at runtime in the classpath at least one another SLF4J binding. Here is mentioned ContextSelectorStaticBinder from Logback that is another binding.
You have to have in the classpath at runtime a single implementation/binding for SLF4J.
To solve your problem, it is rather simple.
As you use Maven, I propose you to execute the mvn dependency:tree command from the agreggator pom of your application or if you have not agreggator pom, from the pom that packages your application.
This command will write as output the dependencies (including transitive dependencies pulled by your pom).
It will output something like that :
[INFO] --- maven-dependency-plugin:2.10:tree (default-cli) # Test-Spring-Boot ---
[INFO] Test-Spring-Boot:Test-Spring-Boot:jar:0.0.1-SNAPSHOT
[INFO] \- org.springframework.boot:spring-boot-starter-web:jar:1.4.4.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter:jar:1.4.4.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:1.4.4.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.4.4.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-logging:jar:1.4.4.RELEASE:compile
[INFO] | | +- ch.qos.logback:logback-classic:jar:1.1.9:compile
[INFO] | | | +- ch.qos.logback:logback-core:jar:1.1.9:compile
[INFO] | | | \- org.slf4j:slf4j-api:jar:1.7.22:compile
[INFO] | | +- org.slf4j:jcl-over-slf4j:jar:1.7.22:compile
[INFO] | | +- org.slf4j:jul-to-slf4j:jar:1.7.22:compile
[INFO] | | \- org.slf4j:log4j-over-slf4j:jar:1.7.22:compile
[INFO] | +- org.springframework:spring-core:jar:4.3.6.RELEASE:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.17:runtime
[INFO] +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.4.4.RELEASE:compile
[INFO] | +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.11:compile
[INFO] | +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.11:compile
[INFO] | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.11:compile
[INFO] +- org.hibernate:hibernate-validator:jar:5.2.4.Final:compile
[INFO] | +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] | \- com.fasterxml:classmate:jar:1.3.3:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.6:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.6:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.8.6:compile
[INFO] +- org.springframework:spring-web:jar:4.3.6.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:4.3.6.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.3.6.RELEASE:compile
[INFO] | \- org.springframework:spring-context:jar:4.3.6.RELEASE:compile
[INFO] \- org.springframework:spring-webmvc:jar:4.3.6.RELEASE:compile
[INFO] \- org.springframework:spring-expression:jar:4.3.6.RELEASE:compile
You have just to identify from where the logback dependency is pulled.
Once having identified it, remove the dependency it if it is an dependency explicitly declared from our own pom.
If it is a transitive dependency, use the exclusion dependency mechanism of Maven.
If you want to use log4j appender to print slf4j logger's log, make sure that you have slf4j-log4j12 jar and remove logback jars, or it will be out of your control whether log4j or logback in use.
When I run "mvn dependency:tree" for my project it shows the following:
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # xxxxx ---
[INFO] com.xxx.xxx:xxxxx:war:3.1.0-SNAPSHOT
...
[INFO] +- commons-configuration:commons-configuration:jar:1.5:compile
[INFO] | \- commons-beanutils:commons-beanutils-core:jar:1.7.0:compile
[INFO] +- org.seleniumhq.selenium:selenium-api:jar:2.34.0:test
[INFO] | +- com.google.guava:guava:jar:14.0:test
[INFO] | \- org.json:json:jar:20080701:test
[INFO] +- org.seleniumhq.selenium:selenium-htmlunit-driver:jar:2.34.0:test
[INFO] | +- org.seleniumhq.selenium:selenium-remote-driver:jar:2.34.0:test
[INFO] | | +- cglib:cglib-nodep:jar:2.1_3:test
[INFO] | | +- net.java.dev.jna:jna:jar:3.4.0:test
[INFO] | | \- net.java.dev.jna:platform:jar:3.4.0:test
[INFO] | \- net.sourceforge.htmlunit:htmlunit:jar:2.12:test
[INFO] | +- org.apache.commons:commons-lang3:jar:3.1:test
[INFO] | +- org.apache.httpcomponents:httpmime:jar:4.2.3:test
[INFO] | +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.12:test
[INFO] | +- xerces:xercesImpl:jar:2.10.0:test
>>>[INFO] | | \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] | +- net.sourceforge.nekohtml:nekohtml:jar:1.9.18:test
[INFO] | +- net.sourceforge.cssparser:cssparser:jar:0.9.9:test
[INFO] | | \- org.w3c.css:sac:jar:1.3:test
[INFO] | \- org.eclipse.jetty:jetty-websocket:jar:8.1.9.v20130131:test
[INFO] +- org.seleniumhq.selenium:selenium-firefox-driver:jar:2.34.0:test
...
As you see on the marked line, the xml-apis has "compile" scope, and as result it is packed into .war file. Why could it happen?
More interestingly it happens only while Java5 is used, for Java6 the dependency appears as "test".
Maven version: 3.0.4
Study the output of the following Maven command.
mvn -X dependency:tree -Dverbose
That should tell you why Maven upgraded the scope from test to compile.
If you take a look at xercesImpl it contains a dependency to xml-apis:xml-apis:jar:1.4.01:compile with the scope compile so the display of dependency plugin is correct. The usage of -Dverbose will do things as written in the docs:
Whether to include omitted nodes in the serialized dependency tree.
Apart from the above a test dependency as in your case is never being packaged into a war file.
There must be an other source of the same dependency which causes the packaging into the war
Furthermore the change in behaviour in relationship with adding explicit xml-apis to your pom is a supplemental evidence for this.
I had a similar problem.
In my case an entry in the dependencyManagement of a parent pom set the scope of the dependent artefact to compile. Actually I omitted the scope tag which effectively is the same as setting it to compile. Changing it to provided helped.
Seems the scope in dependencyManagement takes precedence over the transitive scope. Which makes sense but can still cause confusion when all you wanted to do is define the version.
It was actually not hard to spot: Looking at the effective-pom showed the dependencyManagement entry.