Reputation: 783
I know there's plenty questions like this in StackOverflow, but can't figure it how to resolve my problem:
I'm trying to use logback, but when I try to launch my app, I'm getting this error:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/var/lib/tomcat8/webapps/ROOT/WEB-INF/lib/slf4j-log4j12-1.7.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/var/lib/tomcat8/webapps/ROOT/WEB-INF/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]
log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.StandardServletEnvironment).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Note that how the actual binding is instead Log4j and tried to start log4j, but no appenders found.
I know I have to exclude those libraries who use log4j, I can not figure out which are.
I can't use mvn dependency:tree because it fails due to dependencies with others projects which are implied
8 required artifacts are missing.
From the "Dependency Hierarchy" view in eclipse, still can't find them.
Here is my pom.xml
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>floox</artifactId>
<groupId>com.i3tv</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>floox-business</artifactId>
<packaging>war</packaging>
<name>Floox Business</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<io.spring.platform-version>1.1.1.RELEASE</io.spring.platform-version>
<!-- AssertJ is not a part of Spring IO platform, so the version must be
provided explicitly -->
<assertj-core-version>1.5.0</assertj-core-version>
<config.root>src/main/config</config.root>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>${io.spring.platform-version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<!-- Security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>
<!-- View -->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
<!-- Avoid org.hibernate.jpa.boot.archive.spi.ArchiveException: Could
not build ClassFile in Java 8 -->
<exclusions>
<exclusion>
<artifactId>javassist</artifactId>
<groupId>org.javassist</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity3</artifactId>
</dependency>
<!-- Persistence -->
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<!-- Avoid issue #72 Could not initialize class org.thymeleaf.templateresolver.ServletContextTemplateResolver
due to 'validation is not supported' -->
<exclusions>
<exclusion>
<artifactId>pull-parser</artifactId>
<groupId>pull-parser</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- Avoid: javax.validation.ValidationException: HV000183: Unable to load
'javax.el.ExpressionFactory' -->
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
<!-- Spring Data -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
<!-- Validation -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<!-- Logging -->
< <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<!-- @Inject -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- JSON -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<!-- Utilities -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<!-- Test -->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj-core-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sf.dozer</groupId>
<artifactId>dozer</artifactId>
<version>5.5.1</version>
</dependency>
<dependency>
<groupId>com.i3tv</groupId>
<artifactId>engine-indexer-dto</artifactId>
</dependency>
<dependency>
<groupId>com.i3tv</groupId>
<artifactId>temporal-hits-dto</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.i3tv</groupId>
<artifactId>floox-cloudsearch</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.i3tv</groupId>
<artifactId>floox-dto</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.i3tv</groupId>
<artifactId>floox-aop</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.i3tv</groupId>
<artifactId>floox-memcached</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.i3tv</groupId>
<artifactId>floox-utils</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.i3tv</groupId>
<artifactId>floox-token</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.i3tv.a3cms.social</groupId>
<artifactId>a3cms-social-user</artifactId>
<version>${social.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>de.javakaffee.msm</groupId>
<artifactId>msm-kryo-serializer</artifactId>
<version>1.9.0-RC1</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<!-- Configuración de los perfiles -->
<profiles>
<profile>
<id>local</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<resources>
<resource>
<directory>${config.root}/local</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
</build>
<properties>
<profile.name>local</profile.name>
</properties>
</profile>
<!-- <profile> -->
<!-- <id>pre</id> -->
<!-- <build> -->
<!-- <resources> -->
<!-- <resource> -->
<!-- <directory>${config.root}/pre</directory> -->
<!-- <includes> -->
<!-- <include>**/*</include> -->
<!-- </includes> -->
<!-- </resource> -->
<!-- </resources> -->
<!-- </build> -->
<!-- <properties> -->
<!-- <serverId>aeb-pro</serverId> -->
<!-- <applicationName>Flux</applicationName> -->
<!-- <environmentName>flux-pre</environmentName> -->
<!-- <cnamePrefix>flux-pre</cnamePrefix> -->
<!-- <s3Bucket>flux-pre</s3Bucket> -->
<!-- <profile.name>pre</profile.name> -->
<!-- </properties> -->
<!-- </profile> -->
<profile>
<id>pre</id>
<build>
<resources>
<resource>
<directory>${config.root}/pre</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
</build>
<properties>
<serverId>aeb-pre</serverId>
<applicationName>floox-PRE</applicationName>
<environmentName>flooxPre-env</environmentName>
<cnamePrefix>flooxpre-env</cnamePrefix>
<s3Bucket>fluxpre</s3Bucket>
<profile.name>pre</profile.name>
</properties>
</profile>
<profile>
<id>pro</id>
<build>
<resources>
<resource>
<directory>${config.root}/pro</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
</build>
<properties>
<serverId>aeb-pro</serverId>
<applicationName>Flux</applicationName>
<environmentName>flux-pro</environmentName>
<cnamePrefix>flux-pro</cnamePrefix>
<s3Bucket>flux-pro</s3Bucket>
<profile.name>pro</profile.name>
</properties>
</profile>
</profiles>
<!-- Fin de la configuración de los perfiles -->
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webResources>
<resource>
<directory>${config.root}/${profile.name}/ebextensions</directory>
<targetPath>.ebextensions</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>deploy</id>
<phase>deploy</phase>
<goals>
<goal>sources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>br.com.ingenieux</groupId>
<artifactId>beanstalk-maven-plugin</artifactId>
<version>1.0.1</version>
<configuration>
<serverId>${serverId}</serverId>
<environmentName>${environmentName}</environmentName>
<region>eu-west-1</region>
<applicationName>${applicationName}</applicationName>
<s3Bucket>${s3Bucket}</s3Bucket>
<s3Key>${project.artifactId}/${project.build.finalName}-${maven.build.timestamp}.war</s3Key>
<cnamePrefix>${cnamePrefix}</cnamePrefix>
<solutionStack>64bit Amazon Linux running Tomcat 7</solutionStack>
</configuration>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>upload-source-bundle</goal>
<goal>create-application-version</goal>
<goal>update-environment</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Upvotes: 3
Views: 4058
Reputation: 783
I finally managed to clean my classpath thanks to dur
The problem was that I was trying to exclude log4j from my dependencies instead the slf4j jars.
So and through the Dependency Hierarchy in Eclipse, I was able to find which libraries was using that dependency and then excluded with right click and Exclude Maven Artifact on Resolved Dependencies tab.
That added this code to my pom
<exclusions>
<exclusion>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
And voila, everything worked.
Upvotes: 2