Git Product home page Git Product logo

Comments (3)

spencergibb avatar spencergibb commented on May 18, 2024

@aheusingfeld Eureka itself has a hard dependency on log4j that we are trying to solve. (see #3) spring-boot-starter-logging is already excluded by spring-cloud-netlifx-eureka-server. I don't see logback-classic in the mvn dependency:tree output. Are you seeing a specific problem?

from spring-cloud-netflix.

aheusingfeld avatar aheusingfeld commented on May 18, 2024

Are you seeing a specific problem?

yes. I have a simple Gradle 2.0 build.gradle file like the following:

buildscript {
    repositories {
        maven { url "http://repo.spring.io/libs-release" }
    }
    dependencies {
        classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.1.7.RELEASE'
    }
}

apply plugin: 'java'
apply plugin: 'spring-boot'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility  = JavaVersion.VERSION_1_8
version = '1.0'

repositories {
    mavenCentral()
    maven { url "http://repo.spring.io/libs-snapshot" }
}

dependencies {
    compile 'org.springframework.cloud:spring-cloud-starters:1.0.0.BUILD-SNAPSHOT'
    compile 'org.springframework.cloud:spring-cloud-starter-eureka-server:1.0.0.BUILD-SNAPSHOT'
    testCompile 'org.springframework.boot:spring-boot-starter-test:1.1.7.RELEASE'
}

When I build and run this via java -jar build/libs/eureka-server-1.0.jar, I get the following error

Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Volumes/innoq-dev/microservicesjvm/eureka-server/build/libs/eureka-server-1.0.jar!/lib/slf4j-log4j12-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Volumes/innoq-dev/microservicesjvm/eureka-server/build/libs/eureka-server-1.0.jar!/lib/logback-classic-1.1.2.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.slf4j.impl.Log4jLoggerFactory]
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.Log4jLoggerFactory) Object of class [org.slf4j.impl.Log4jLoggerFactory] must be an instance of class ch.qos.logback.classic.LoggerContext
    at org.springframework.util.Assert.isInstanceOf(Assert.java:339)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:93)
    at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithSensibleDefaults(AbstractLoggingSystem.java:62)
    at org.springframework.boot.logging.AbstractLoggingSystem.beforeInitialize(AbstractLoggingSystem.java:45)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:69)
    at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:135)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:98)
    at org.springframework.boot.context.event.EventPublishingRunListener.publishEvent(EventPublishingRunListener.java:100)
    at org.springframework.boot.context.event.EventPublishingRunListener.started(EventPublishingRunListener.java:54)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:276)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:952)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:941)

Therefore I had to manually exclude logback classic in the build.gradle like the following

    compile ('org.springframework.cloud:spring-cloud-starter-eureka-server:1.0.0.BUILD-SNAPSHOT') {
        exclude module: 'logback-classic'
    }

Another problem is that the transitive dependencies of the spring-cloud-starters don't seem to be loaded, but that's a different topic which is probably also the cause for #22

from spring-cloud-netflix.

dsyer avatar dsyer commented on May 18, 2024

It should be clear from #22 that it is caused by Jersey classpath scanning, and the fix is explained (and exemplified for Maven in a sample). But "spring-boot-starters" doesn't have any transitive dependencies, so it's not surprising that they aren't being used. Did you mean to use "spring-boot-starter" (singular)? You do sometimes have to do some manual dependency exclusion when you work with Gradle, but if you only want to run the eureka server it should be enough to just depend on the "spring-cloud-starter-eureka-server".

from spring-cloud-netflix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.