Dependency log4j-slf4j-impl for solr-core:7.5.0 causing a number of build problems

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Dependency log4j-slf4j-impl for solr-core:7.5.0 causing a number of build problems

Wolf, Chris (ELS-CON)
I am having several issues due to the slf4j implementation dependency “log4j-slf4j-impl” being declared as a dependency of solr-core:7.5.0.   The first issue observed when starting the app is this:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/ma-wolf2/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.7/log4j-slf4j-impl-2.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/ma-wolf2/.m2/repository/ch/qos/logback/logback-classic/1.1.3/logback-classic-1.1.3.jar!/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.apache.logging.slf4j.Log4jLoggerFactory]

I first got wind that this might not be just myself from this thread:
https://lucene.472066.n3.nabble.com/log4j-slf4j-impl-dependency-in-solr-core-td4449635.html#a4449891


  *   If there are any users that integrate solr-core into their own code,
it's currently a bit of a land-mine situation to change logging
implementations.  If there's a way we can include log4j jars at build
time, but remove the log4j dependency on the published solr-core
artifact, that might work well.  We should do our best to make it so
people can use EmbeddedSolrServer without log4j jars.

There are two dimensions to this dependency problem:

  *   Building a war file (this runs with a warning)
  *   Building a spring-boot executable JAR with embedded servlet container (doesn’t run)

When building a WAR and deploying, I get the “multiple SLF4J bindings” warning, but the app works. However, I want the convenience of a spring-boot executable JAR with embedded servlet container, but in that case, I get that warning followed by a fatal NoClassDefFoundError/ ClassNotFoundException – which is a show-stopper.  If I hack the built spring-boot FAT jar and remove “log4j-slf4j-impl.jar” then the app works.

For the WAR build, the proper version of log4j-slf4j-impl.jar was included – 2.11.0, but,for some reason when building the spring-boot fat (uber) jar, it was building with log4j-slf4j-impl:2.7 so of course it will croak.

There are several issues:

  1.  I don’t want log4j-slf4j-impl at all
  2.  Somehow the version of “log4j-slf4j-impl” being used for the build is 2.7 rather then the expected 2.11.0
  3.  Due to the version issue, the app croaks with ClassNotFoundException: org.apache.logging.log4j.util.ReflectionUtil

For issue #1, I tried:
  <dependency>
      <groupId>org.apache.solr</groupId>
      <artifactId>solr-core</artifactId>
      <version>7.5.0</version>
      <exclusions>
        <exclusion>
          <artifactId>org.apache.logging.log4j</artifactId>
          <groupId>log4j-slf4j-impl</groupId>
        </exclusion>
      </exclusions>
    </dependency>

All to no avail, as that dependency ends up in the packaged build - for WAR, it’s version 2.11.0, so even though it’s a bad build, the app runs, but for building a spring-boot executable JAR with embedded webserver, for some reason, it switches log4j-slf4j-impl from version 2.11.0  to 2,7 (2.11.0  works, but should not even be there)

I also tried this:
https://docs.spring.io/spring-boot/docs/current/maven-plugin/examples/exclude-dependency.html

…that didn’t work either.

I’m thinking that solr-core should have added a classifier of “provided” for “log4j-slf4j-impl”, but that’s conjecture of a possible solution going forward, but does anyone know how I can exclude  “log4j-slf4j-impl”  from a spring-boot build?





Reply | Threaded
Open this post in threaded view
|

Re: Dependency log4j-slf4j-impl for solr-core:7.5.0 causing a number of build problems

Mark H. Wood
On Thu, Jan 16, 2020 at 02:03:06AM +0000, Wolf, Chris (ELS-CON) wrote:
[snip]

> There are several issues:
>
>   1.  I don’t want log4j-slf4j-impl at all
>   2.  Somehow the version of “log4j-slf4j-impl” being used for the build is 2.7 rather then the expected 2.11.0
>   3.  Due to the version issue, the app croaks with ClassNotFoundException: org.apache.logging.log4j.util.ReflectionUtil
>
> For issue #1, I tried:
>   <dependency>
>       <groupId>org.apache.solr</groupId>
>       <artifactId>solr-core</artifactId>
>       <version>7.5.0</version>
>       <exclusions>
>         <exclusion>
>           <artifactId>org.apache.logging.log4j</artifactId>
>           <groupId>log4j-slf4j-impl</groupId>
>         </exclusion>
>       </exclusions>
>     </dependency>
>
> All to no avail, as that dependency ends up in the packaged build - for WAR, it’s version 2.11.0, so even though it’s a bad build, the app runs, but for building a spring-boot executable JAR with embedded webserver, for some reason, it switches log4j-slf4j-impl from version 2.11.0  to 2,7 (2.11.0  works, but should not even be there)
>
> I also tried this:
> https://docs.spring.io/spring-boot/docs/current/maven-plugin/examples/exclude-dependency.html
>
> …that didn’t work either.
>
> I’m thinking that solr-core should have added a classifier of “provided” for “log4j-slf4j-impl”, but that’s conjecture of a possible solution going forward, but does anyone know how I can exclude  “log4j-slf4j-impl”  from a spring-boot build?
It looks to me as though solr-core is not the only artifact with that
dependency.  The first thing I would do is examine the output of 'mvn
dependency:tree' to see what has dragged log4j-slf4j-impl in even when
it is excluded from solr-core.

--
Mark H. Wood
Lead Technology Analyst

University Library
Indiana University - Purdue University Indianapolis
755 W. Michigan Street
Indianapolis, IN 46202
317-274-0749
www.ulib.iupui.edu

signature.asc (201 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Dependency log4j-slf4j-impl for solr-core:7.5.0 causing a number of build problems

Wolf, Chris (ELS-CON)
--- original message ---
It looks to me as though solr-core is not the only artifact with that
dependency.  The first thing I would do is examine the output of 'mvn
dependency:tree' to see what has dragged log4j-slf4j-impl in even when
it is excluded from solr-core.
--- end of original message ---

Hi, that's the first thing I did and *only* solr-core is pulling in log4j-slf4j-impl, but there is more weirdness to this.  When I build as a WAR project, then version 2.11.0 of in log4j-slf4j-impl is pulled in which results in "multiple implementations" warning and is non-fatal.  

However, when building as a spring-boot executable jar, for some reason, it pulls in version 2.7 rather then 2.11.0 resulting in fatal "ClassNotFoundException: org.apache.logging.log4j.util.ReflectionUtil"

Thanks.

Here is the dependency tree:

com.elsevier:<spring-boot executable-jar>:jar:1.1.7
+- org.springframework.boot:spring-boot-starter-web:jar:1.5.6.RELEASE:compile
|  +- org.springframework.boot:spring-boot-starter:jar:1.5.6.RELEASE:compile
|  |  +- org.springframework.boot:spring-boot:jar:1.5.6.RELEASE:compile
|  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.6.RELEASE:compile
|  |  +- org.springframework.boot:spring-boot-starter-logging:jar:1.5.6.RELEASE:compile
|  |  +- org.springframework:spring-core:jar:4.3.10.RELEASE:compile
|  |  \- org.yaml:snakeyaml:jar:1.17:runtime
|  +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.5.6.RELEASE:compile
|  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.16:compile
|  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.16:compile
|  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.16:compile
|  +- org.hibernate:hibernate-validator:jar:5.3.5.Final:compile
|  |  +- javax.validation:validation-api:jar:1.1.0.Final:compile
|  |  +- org.jboss.logging:jboss-logging:jar:3.3.1.Final:compile
|  |  \- com.fasterxml:classmate:jar:1.3.3:compile
|  +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.9:compile
|  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
|  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.8.9:compile
|  +- org.springframework:spring-web:jar:4.3.10.RELEASE:compile
|  |  +- org.springframework:spring-aop:jar:4.3.10.RELEASE:compile
|  |  +- org.springframework:spring-beans:jar:4.3.10.RELEASE:compile
|  |  \- org.springframework:spring-context:jar:4.3.10.RELEASE:compile
|  \- org.springframework:spring-webmvc:jar:4.3.10.RELEASE:compile
|     \- org.springframework:spring-expression:jar:4.3.10.RELEASE:compile
+- cglib:cglib-nodep:jar:3.0:runtime
+- org.apache.commons:commons-lang3:jar:3.1:compile
+- org.jdom:jdom2:jar:2.0.6:compile
+- com.example.somelibjar:jar:1.1.9:compile
|  +- org.apache.lucene:lucene-core:jar:7.5.0:compile
|  +- com.healthline:qpe:jar:1.1.5:compile
|  |  +- org.springframework:spring-context-support:jar:4.3.10.RELEASE:compile
|  |  +- org.springframework:spring-jdbc:jar:4.3.10.RELEASE:compile
|  |  |  \- org.springframework:spring-tx:jar:4.3.10.RELEASE:compile
|  |  \- org.apache.logging.log4j:log4j-core:jar:2.7:compile
|  +- com.exampe:somelib2:jar:1.1.4:compile
|  |  +- org.apache.solr:solr-core:jar:7.5.0:compile
|  |  |  +- org.apache.lucene:lucene-analyzers-common:jar:7.5.0:compile
|  |  |  +- org.apache.lucene:lucene-analyzers-kuromoji:jar:7.5.0:compile
|  |  |  +- org.apache.lucene:lucene-analyzers-nori:jar:7.5.0:compile
|  |  |  +- org.apache.lucene:lucene-analyzers-phonetic:jar:7.5.0:compile
|  |  |  +- org.apache.lucene:lucene-backward-codecs:jar:7.5.0:compile
|  |  |  +- org.apache.lucene:lucene-classification:jar:7.5.0:compile
|  |  |  +- org.apache.lucene:lucene-codecs:jar:7.5.0:compile
|  |  |  +- org.apache.lucene:lucene-expressions:jar:7.5.0:compile
|  |  |  +- org.apache.lucene:lucene-grouping:jar:7.5.0:compile
|  |  |  +- org.apache.lucene:lucene-highlighter:jar:7.5.0:compile
|  |  |  +- org.apache.lucene:lucene-join:jar:7.5.0:compile
|  |  |  +- org.apache.lucene:lucene-memory:jar:7.5.0:compile
|  |  |  +- org.apache.lucene:lucene-misc:jar:7.5.0:compile
|  |  |  +- org.apache.lucene:lucene-queries:jar:7.5.0:compile
|  |  |  +- org.apache.lucene:lucene-queryparser:jar:7.5.0:compile
|  |  |  +- org.apache.lucene:lucene-sandbox:jar:7.5.0:compile
|  |  |  +- org.apache.lucene:lucene-spatial-extras:jar:7.5.0:compile
|  |  |  +- org.apache.lucene:lucene-spatial3d:jar:7.5.0:compile
|  |  |  +- org.apache.lucene:lucene-suggest:jar:7.5.0:compile
|  |  |  +- com.carrotsearch:hppc:jar:0.8.1:compile
|  |  |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar:2.8.9:compile
|  |  |  +- com.github.ben-manes.caffeine:caffeine:jar:2.3.5:compile
|  |  |  +- com.google.guava:guava:jar:14.0.1:compile
|  |  |  +- com.google.protobuf:protobuf-java:jar:3.1.0:compile
|  |  |  +- com.lmax:disruptor:jar:3.4.0:compile
|  |  |  +- com.tdunning:t-digest:jar:3.1:compile
|  |  |  +- commons-codec:commons-codec:jar:1.10:compile
|  |  |  +- commons-configuration:commons-configuration:jar:1.6:compile
|  |  |  +- commons-fileupload:commons-fileupload:jar:1.3.3:compile
|  |  |  +- commons-lang:commons-lang:jar:2.6:compile
|  |  |  +- dom4j:dom4j:jar:1.6.1:compile
|  |  |  +- info.ganglia.gmetric4j:gmetric4j:jar:1.0.7:compile
|  |  |  +- io.dropwizard.metrics:metrics-core:jar:3.1.5:compile
|  |  |  +- io.dropwizard.metrics:metrics-ganglia:jar:3.1.5:compile
|  |  |  +- io.dropwizard.metrics:metrics-graphite:jar:3.1.5:compile
|  |  |  +- io.dropwizard.metrics:metrics-jetty9:jar:3.2.6:compile
|  |  |  +- io.dropwizard.metrics:metrics-jvm:jar:3.2.6:compile
|  |  |  +- javax.servlet:javax.servlet-api:jar:3.1.0:compile
|  |  |  +- joda-time:joda-time:jar:2.9.9:compile
|  |  |  +- org.antlr:antlr4-runtime:jar:4.5.1-1:compile
|  |  |  +- org.apache.calcite:calcite-core:jar:1.13.0:compile
|  |  |  +- org.apache.calcite:calcite-linq4j:jar:1.13.0:compile
|  |  |  +- org.apache.calcite.avatica:avatica-core:jar:1.10.0:compile
|  |  |  +- org.apache.commons:commons-exec:jar:1.3:compile
|  |  |  +- org.apache.commons:commons-math3:jar:3.6.1:compile
|  |  |  +- org.apache.curator:curator-client:jar:2.8.0:compile
|  |  |  +- org.apache.curator:curator-framework:jar:2.8.0:compile
|  |  |  +- org.apache.curator:curator-recipes:jar:2.8.0:compile
|  |  |  +- org.apache.hadoop:hadoop-annotations:jar:2.7.4:compile
|  |  |  |  \- jdk.tools:jdk.tools:jar:1.8:system
|  |  |  +- org.apache.hadoop:hadoop-auth:jar:2.7.4:compile
|  |  |  +- org.apache.hadoop:hadoop-common:jar:2.7.4:compile
|  |  |  +- org.apache.hadoop:hadoop-hdfs:jar:2.7.4:compile
|  |  |  +- org.apache.htrace:htrace-core:jar:3.2.0-incubating:compile
|  |  |  +- org.apache.httpcomponents:httpclient:jar:4.5.3:compile
|  |  |  +- org.apache.httpcomponents:httpcore:jar:4.4.6:compile
|  |  |  +- org.apache.httpcomponents:httpmime:jar:4.5.3:compile
|  |  |  +- org.apache.logging.log4j:log4j-1.2-api:jar:2.7:compile
|  |  |  +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.7:compile <<<===========
|  |  |  +- org.apache.zookeeper:zookeeper:jar:3.4.11:compile
|  |  |  +- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
|  |  |  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
|  |  |  +- org.codehaus.janino:commons-compiler:jar:2.7.6:compile
|  |  |  +- org.codehaus.janino:janino:jar:2.7.8:compile
|  |  |  +- org.codehaus.woodstox:stax2-api:jar:3.1.4:compile
|  |  |  +- org.codehaus.woodstox:woodstox-core-asl:jar:4.4.1:compile
|  |  |  +- org.eclipse.jetty:jetty-continuation:jar:9.4.6.v20170531:compile
|  |  |  +- org.eclipse.jetty:jetty-deploy:jar:9.4.6.v20170531:compile
|  |  |  +- org.eclipse.jetty:jetty-http:jar:9.4.6.v20170531:compile
|  |  |  +- org.eclipse.jetty:jetty-io:jar:9.4.6.v20170531:compile
|  |  |  +- org.eclipse.jetty:jetty-jmx:jar:9.4.6.v20170531:compile
|  |  |  +- org.eclipse.jetty:jetty-rewrite:jar:9.4.6.v20170531:compile
|  |  |  |  \- org.eclipse.jetty:jetty-client:jar:9.4.6.v20170531:compile
|  |  |  +- org.eclipse.jetty:jetty-security:jar:9.4.6.v20170531:compile
|  |  |  +- org.eclipse.jetty:jetty-server:jar:9.4.6.v20170531:compile
|  |  |  +- org.eclipse.jetty:jetty-servlet:jar:9.4.6.v20170531:compile
|  |  |  +- org.eclipse.jetty:jetty-servlets:jar:9.4.6.v20170531:compile
|  |  |  +- org.eclipse.jetty:jetty-util:jar:9.4.6.v20170531:compile
|  |  |  +- org.eclipse.jetty:jetty-webapp:jar:9.4.6.v20170531:compile
|  |  |  +- org.eclipse.jetty:jetty-xml:jar:9.4.6.v20170531:compile
|  |  |  +- org.locationtech.spatial4j:spatial4j:jar:0.7:compile
|  |  |  +- org.noggit:noggit:jar:0.8:compile
|  |  |  +- org.ow2.asm:asm:jar:5.1:compile
|  |  |  +- org.ow2.asm:asm-commons:jar:5.1:compile
|  |  |  +- org.restlet.jee:org.restlet:jar:2.3.0:compile
|  |  |  +- org.restlet.jee:org.restlet.ext.servlet:jar:2.3.0:compile
|  |  |  \- org.rrd4j:rrd4j:jar:3.2:compile
|  |  +- net.htmlparser.jericho:jericho-html:jar:2.5:compile
|  |  +- commons-collections:commons-collections:jar:3.2.2:compile
|  |  +- commons-beanutils:commons-beanutils:jar:1.9.3:compile
|  |  +- org.codehaus.jackson:jackson-smile:jar:1.8.5:compile
|  |  +- org.codehaus.jackson:jackson-xc:jar:1.8.5:compile
|  |  +- org.codehaus.jackson:jackson-mrbean:jar:1.8.5:compile
|  |  +- org.json:json:jar:20140107:compile
|  |  +- commons-httpclient:commons-httpclient:jar:3.1:compile
|  |  +- javax.mail:mail:jar:1.4.7:compile
|  |  |  \- javax.activation:activation:jar:1.1:compile
|  |  +- net.sf.ehcache:ehcache-core:jar:2.4.7:compile
|  |  +- bouncycastle:bcprov-jdk15:jar:133:compile
|  |  +- net.sourceforge.csvjdbc:csvjdbc:jar:1.0.34:compile
|  |  +- org.apache.jena:apache-jena-libs:pom:3.9.0:compile
|  |  |  +- org.apache.jena:jena-tdb:jar:3.9.0:compile
|  |  |  |  \- org.apache.jena:jena-arq:jar:3.9.0:compile
|  |  |  |     +- org.apache.jena:jena-core:jar:3.9.0:compile
|  |  |  |     |  +- org.apache.jena:jena-iri:jar:3.9.0:compile
|  |  |  |     |  \- org.apache.jena:jena-base:jar:3.9.0:compile
|  |  |  |     |     +- org.apache.commons:commons-csv:jar:1.5:compile
|  |  |  |     |     +- org.apache.commons:commons-compress:jar:1.17:compile
|  |  |  |     |     \- com.github.andrewoma.dexx:collection:jar:0.7:compile
|  |  |  |     +- org.apache.jena:jena-shaded-guava:jar:3.9.0:compile
|  |  |  |     +- com.github.jsonld-java:jsonld-java:jar:0.12.1:compile
|  |  |  |     +- org.apache.httpcomponents:httpclient-cache:jar:4.5.5:compile
|  |  |  |     \- org.apache.thrift:libthrift:jar:0.10.0:compile
|  |  |  +- org.apache.jena:jena-tdb2:jar:3.9.0:compile
|  |  |  |  \- org.apache.jena:jena-dboe-trans-data:jar:3.9.0:compile
|  |  |  |     +- org.apache.jena:jena-dboe-transaction:jar:3.9.0:compile
|  |  |  |     |  \- org.apache.jena:jena-dboe-base:jar:3.9.0:compile
|  |  |  |     \- org.apache.jena:jena-dboe-index:jar:3.9.0:compile
|  |  |  \- org.apache.jena:jena-rdfconnection:jar:3.9.0:compile
|  |  \- org.apache.jena:jena-jdbc-driver-bundle:jar:3.9.0:compile
|  |     +- org.apache.jena:jena-jdbc-driver-mem:jar:3.9.0:compile
|  |     |  \- org.apache.jena:jena-jdbc-core:jar:3.9.0:compile
|  |     +- org.apache.jena:jena-jdbc-driver-remote:jar:3.9.0:compile
|  |     \- org.apache.jena:jena-jdbc-driver-tdb:jar:3.9.0:compile
|  +- com.healthline:hl-cm:jar:1.1.2:compile
|  |  +- org.apache.poi:poi:jar:3.7:compile
|  |  +- org.apache.commons:commons-math:jar:2.0:compile
|  |  +- jaxen:jaxen:jar:1.1.6:compile
|  |  \- net.sf.jazzy:jazzy-core:jar:0.5.2:compile
|  +- com.elsevier:ckcommons:jar:1.1.5:compile
|  |  +- commons-cli:commons-cli:jar:1.2:compile
|  |  +- org.apache.solr:solr-solrj:jar:5.5.4:compile
|  |  +- com.amazonaws:aws-java-sdk-core:jar:1.11.487:compile
|  |  |  +- software.amazon.ion:ion-java:jar:1.0.2:compile
|  |  |  \- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.8.9:compile
|  |  +- com.amazonaws:aws-java-sdk-s3:jar:1.11.487:compile
|  |  |  +- com.amazonaws:aws-java-sdk-kms:jar:1.11.487:compile
|  |  |  \- com.amazonaws:jmespath-java:jar:1.11.487:compile
|  |  \- com.google.code.gson:gson:jar:2.8.1:compile
|  +- commons-io:commons-io:jar:1.4:compile
|  \- net.sourceforge.collections:collections-generic:jar:4.01:compile
+- com.oracle:ojdbc-jdk8:jar:12.2.0.1:compile
+- com.oracle:ucp-jdk8:jar:12.2.0.1:compile
+- org.apache.logging.log4j:log4j-api:jar:2.11.0:compile
+- org.slf4j:slf4j-api:jar:1.7.25:compile
+- org.slf4j:jcl-over-slf4j:jar:1.7.25:compile
+- org.slf4j:log4j-over-slf4j:jar:1.7.25:compile
+- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
+- ch.qos.logback:logback-classic:jar:1.1.3:compile
+- ch.qos.logback:logback-core:jar:1.1.3:compile
+- ch.qos.logback:logback-access:jar:1.1.3:compile
+- commons-logging:commons-logging:jar:1.2:provided
+- commons-logging:commons-logging-api:jar:1.1:provided
+- log4j:log4j:jar:1.2.17:provided
+- junit:junit:jar:4.11:test
|  \- org.hamcrest:hamcrest-core:jar:1.3:test
\- org.mockito:mockito-core:jar:2.23.0:test
   +- net.bytebuddy:byte-buddy:jar:1.9.0:test
   +- net.bytebuddy:byte-buddy-agent:jar:1.9.0:test
   \- org.objenesis:objenesis:jar:2.6:test
On 1/16/20, 9:09 AM, "Mark H. Wood" <[hidden email]> wrote:

    *** External email: use caution ***
   
   
   

Reply | Threaded
Open this post in threaded view
|

Re: Dependency log4j-slf4j-impl for solr-core:7.5.0 causing a number of build problems

david.w.smiley@gmail.com
In reply to this post by Wolf, Chris (ELS-CON)
Ultimately if you deduce the problem, file a JIRA issue and share it with
me; I will look into it.  I care about this matter too; I hate having to
exclude logging dependencies on the consuming end.

~ David Smiley
Apache Lucene/Solr Search Developer
http://www.linkedin.com/in/davidwsmiley


On Wed, Jan 15, 2020 at 9:03 PM Wolf, Chris (ELS-CON) <[hidden email]>
wrote:

> I am having several issues due to the slf4j implementation dependency
> “log4j-slf4j-impl” being declared as a dependency of solr-core:7.5.0.   The
> first issue observed when starting the app is this:
>
> SLF4J: Class path contains multiple SLF4J bindings.
> SLF4J: Found binding in
> [jar:file:/Users/ma-wolf2/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.7/log4j-slf4j-impl-2.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
> SLF4J: Found binding in
> [jar:file:/Users/ma-wolf2/.m2/repository/ch/qos/logback/logback-classic/1.1.3/logback-classic-1.1.3.jar!/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.apache.logging.slf4j.Log4jLoggerFactory]
>
> I first got wind that this might not be just myself from this thread:
>
> https://lucene.472066.n3.nabble.com/log4j-slf4j-impl-dependency-in-solr-core-td4449635.html#a4449891
>
>
>   *   If there are any users that integrate solr-core into their own code,
> it's currently a bit of a land-mine situation to change logging
> implementations.  If there's a way we can include log4j jars at build
> time, but remove the log4j dependency on the published solr-core
> artifact, that might work well.  We should do our best to make it so
> people can use EmbeddedSolrServer without log4j jars.
>
> There are two dimensions to this dependency problem:
>
>   *   Building a war file (this runs with a warning)
>   *   Building a spring-boot executable JAR with embedded servlet
> container (doesn’t run)
>
> When building a WAR and deploying, I get the “multiple SLF4J bindings”
> warning, but the app works. However, I want the convenience of a
> spring-boot executable JAR with embedded servlet container, but in that
> case, I get that warning followed by a fatal NoClassDefFoundError/
> ClassNotFoundException – which is a show-stopper.  If I hack the built
> spring-boot FAT jar and remove “log4j-slf4j-impl.jar” then the app works.
>
> For the WAR build, the proper version of log4j-slf4j-impl.jar was included
> – 2.11.0, but,for some reason when building the spring-boot fat (uber) jar,
> it was building with log4j-slf4j-impl:2.7 so of course it will croak.
>
> There are several issues:
>
>   1.  I don’t want log4j-slf4j-impl at all
>   2.  Somehow the version of “log4j-slf4j-impl” being used for the build
> is 2.7 rather then the expected 2.11.0
>   3.  Due to the version issue, the app croaks with
> ClassNotFoundException: org.apache.logging.log4j.util.ReflectionUtil
>
> For issue #1, I tried:
>   <dependency>
>       <groupId>org.apache.solr</groupId>
>       <artifactId>solr-core</artifactId>
>       <version>7.5.0</version>
>       <exclusions>
>         <exclusion>
>           <artifactId>org.apache.logging.log4j</artifactId>
>           <groupId>log4j-slf4j-impl</groupId>
>         </exclusion>
>       </exclusions>
>     </dependency>
>
> All to no avail, as that dependency ends up in the packaged build - for
> WAR, it’s version 2.11.0, so even though it’s a bad build, the app runs,
> but for building a spring-boot executable JAR with embedded webserver, for
> some reason, it switches log4j-slf4j-impl from version 2.11.0  to 2,7
> (2.11.0  works, but should not even be there)
>
> I also tried this:
>
> https://docs.spring.io/spring-boot/docs/current/maven-plugin/examples/exclude-dependency.html
>
> …that didn’t work either.
>
> I’m thinking that solr-core should have added a classifier of “provided”
> for “log4j-slf4j-impl”, but that’s conjecture of a possible solution going
> forward, but does anyone know how I can exclude  “log4j-slf4j-impl”  from a
> spring-boot build?
>
>
>
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Dependency log4j-slf4j-impl for solr-core:7.5.0 causing a number of build problems

Mark H. Wood
In reply to this post by Wolf, Chris (ELS-CON)
On Thu, Jan 16, 2020 at 03:13:17PM +0000, Wolf, Chris (ELS-CON) wrote:

> --- original message ---
> It looks to me as though solr-core is not the only artifact with that
> dependency.  The first thing I would do is examine the output of 'mvn
> dependency:tree' to see what has dragged log4j-slf4j-impl in even when
> it is excluded from solr-core.
> --- end of original message ---
>
> Hi, that's the first thing I did and *only* solr-core is pulling in log4j-slf4j-impl, but there is more weirdness to this.  When I build as a WAR project, then version 2.11.0 of in log4j-slf4j-impl is pulled in which results in "multiple implementations" warning and is non-fatal.  
>
> However, when building as a spring-boot executable jar, for some reason, it pulls in version 2.7 rather then 2.11.0 resulting in fatal "ClassNotFoundException: org.apache.logging.log4j.util.ReflectionUtil"
For the version problem, I would try adding something like:

  <dependencyManagement>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-slf4j-impl</artifactId>
      <version>2.11.0</version>
    </dependency>
  </dependencyManagement>

to pin down the version no matter what is pulling it in.  Not ideal,
since you want to be rid of this dependency altogether, but at least
it may allow the spring-boot artifact to run, until the other problem
is sorted.

--
Mark H. Wood
Lead Technology Analyst

University Library
Indiana University - Purdue University Indianapolis
755 W. Michigan Street
Indianapolis, IN 46202
317-274-0749
www.ulib.iupui.edu

signature.asc (201 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Dependency log4j-slf4j-impl for solr-core:7.5.0 causing a number of build problems

Wolf, Chris (ELS-CON)
In reply to this post by david.w.smiley@gmail.com
(I found this stuck in my outbox, sorry for the delayed response)

Hi,

Thank you, I finally was able to configure maven to exclude that logging implementation.  But now I'm having an issue building a Spring-Boot executable WAR with embedded Tomcat, for some reason, when I "spring-boot:run" it, it seems to use embedded Jetty rather then embedded Tomcat.  I *think* it's because "solr-core" has transitive dependency on jetty jars.  I will file a Jira when I get to the bottom of this as well.

Thanks for getting back to me.

-Chris

On 1/16/20, 10:49 PM, "David Smiley" <[hidden email]> wrote:

    *** External email: use caution ***
   
   
   
    Ultimately if you deduce the problem, file a JIRA issue and share it with
    me; I will look into it.  I care about this matter too; I hate having to
    exclude logging dependencies on the consuming end.
   
    ~ David Smiley
    Apache Lucene/Solr Search Developer
    http://www.linkedin.com/in/davidwsmiley
   
   
    On Wed, Jan 15, 2020 at 9:03 PM Wolf, Chris (ELS-CON) <[hidden email]>
    wrote:
   
    > I am having several issues due to the slf4j implementation dependency
    > “log4j-slf4j-impl” being declared as a dependency of solr-core:7.5.0.   The
    > first issue observed when starting the app is this:
    >
    > SLF4J: Class path contains multiple SLF4J bindings.
    > SLF4J: Found binding in
    > [jar:file:/Users/ma-wolf2/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.7/log4j-slf4j-impl-2.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    > SLF4J: Found binding in
    > [jar:file:/Users/ma-wolf2/.m2/repository/ch/qos/logback/logback-classic/1.1.3/logback-classic-1.1.3.jar!/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.apache.logging.slf4j.Log4jLoggerFactory]
    >
    > I first got wind that this might not be just myself from this thread:
    >
    > https://lucene.472066.n3.nabble.com/log4j-slf4j-impl-dependency-in-solr-core-td4449635.html#a4449891
    >
    >
    >   *   If there are any users that integrate solr-core into their own code,
    > it's currently a bit of a land-mine situation to change logging
    > implementations.  If there's a way we can include log4j jars at build
    > time, but remove the log4j dependency on the published solr-core
    > artifact, that might work well.  We should do our best to make it so
    > people can use EmbeddedSolrServer without log4j jars.
    >
    > There are two dimensions to this dependency problem:
    >
    >   *   Building a war file (this runs with a warning)
    >   *   Building a spring-boot executable JAR with embedded servlet
    > container (doesn’t run)
    >
    > When building a WAR and deploying, I get the “multiple SLF4J bindings”
    > warning, but the app works. However, I want the convenience of a
    > spring-boot executable JAR with embedded servlet container, but in that
    > case, I get that warning followed by a fatal NoClassDefFoundError/
    > ClassNotFoundException – which is a show-stopper.  If I hack the built
    > spring-boot FAT jar and remove “log4j-slf4j-impl.jar” then the app works.
    >
    > For the WAR build, the proper version of log4j-slf4j-impl.jar was included
    > – 2.11.0, but,for some reason when building the spring-boot fat (uber) jar,
    > it was building with log4j-slf4j-impl:2.7 so of course it will croak.
    >
    > There are several issues:
    >
    >   1.  I don’t want log4j-slf4j-impl at all
    >   2.  Somehow the version of “log4j-slf4j-impl” being used for the build
    > is 2.7 rather then the expected 2.11.0
    >   3.  Due to the version issue, the app croaks with
    > ClassNotFoundException: org.apache.logging.log4j.util.ReflectionUtil
    >
    > For issue #1, I tried:
    >   <dependency>
    >       <groupId>org.apache.solr</groupId>
    >       <artifactId>solr-core</artifactId>
    >       <version>7.5.0</version>
    >       <exclusions>
    >         <exclusion>
    >           <artifactId>org.apache.logging.log4j</artifactId>
    >           <groupId>log4j-slf4j-impl</groupId>
    >         </exclusion>
    >       </exclusions>
    >     </dependency>
    >
    > All to no avail, as that dependency ends up in the packaged build - for
    > WAR, it’s version 2.11.0, so even though it’s a bad build, the app runs,
    > but for building a spring-boot executable JAR with embedded webserver, for
    > some reason, it switches log4j-slf4j-impl from version 2.11.0  to 2,7
    > (2.11.0  works, but should not even be there)
    >
    > I also tried this:
    >
    > https://docs.spring.io/spring-boot/docs/current/maven-plugin/examples/exclude-dependency.html
    >
    > …that didn’t work either.
    >
    > I’m thinking that solr-core should have added a classifier of “provided”
    > for “log4j-slf4j-impl”, but that’s conjecture of a possible solution going
    > forward, but does anyone know how I can exclude  “log4j-slf4j-impl”  from a
    > spring-boot build?
    >
    >
    >
    >
    >
    >
   

Reply | Threaded
Open this post in threaded view
|

Re: Dependency log4j-slf4j-impl for solr-core:7.5.0 causing a number of build problems

Wolf, Chris (ELS-CON)
In reply to this post by Mark H. Wood
(sorry for bad formatting Outlook-for-Mac doesn't support Internet quoting)

Thanks Mark, I did that until I finally was able to exclude it altogether.

-Chris

On 1/17/20, 10:20 AM, "Mark H. Wood" <[hidden email]> wrote:

    For the version problem, I would try adding something like:
   
      <dependencyManagement>
        <dependency>
          <groupId>org.apache.logging.log4j</groupId>
          <artifactId>log4j-slf4j-impl</artifactId>
          <version>2.11.0</version>
        </dependency>
      </dependencyManagement>
   
    to pin down the version no matter what is pulling it in.  Not ideal,
    since you want to be rid of this dependency altogether, but at least
    it may allow the spring-boot artifact to run, until the other problem
    is sorted.