I am trying to enable my SLF4J logger but get the following console message:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Even after I have added these two dependencies to my pom.xml but still have the same message:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.5</version>
</dependency>
I am testing out my logger like this
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
...
//Logger
private static final Logger logger = LoggerFactory.getLogger(Hello.class);
...
logger.info("Test - - - Log message...");
I am new to Spring/Maven and thought this would be easy to solve but have had no success...
Edit:
Here is my Maven pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myfakecompany.project</groupId>
<artifactId>SpringApp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>Spring MVC Webapp</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-cassandra</artifactId>
<version>1.4.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.3.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.5</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>spring-milestone</id>
<name>Spring Maven MILESTONE Repository</name>
<url>http://repo.spring.io/libs-milestone</url>
</repository>
</repositories>
<build>
<finalName>SpringMVCApp</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path>
<contextReloadable>true</contextReloadable>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Edit 2:
#Ceki, here is the mvn dependency:tree output...
[INFO] com.myfakecompany.project:SpringApp:war:1.0-SNAPSHOT
[INFO] +- junit:junit:jar:3.8.1:test
[INFO] +- org.springframework:spring-webmvc:jar:4.2.3.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.2.3.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:4.2.3.RELEASE:compile
[INFO] | | \- org.springframework:spring-aop:jar:4.2.3.RELEASE:compile
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework:spring-core:jar:4.2.3.RELEASE:compile
[INFO] | | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] | +- org.springframework:spring-expression:jar:4.2.3.RELEASE:compile
[INFO] | \- org.springframework:spring-web:jar:4.2.3.RELEASE:compile
[INFO] +- org.springframework.data:spring-data-cassandra:jar:1.4.5.RELEASE:compile
[INFO] | +- org.springframework.data:spring-cql:jar:1.4.5.RELEASE:compile
[INFO] | | \- com.google.guava:guava:jar:19.0:compile
[INFO] | +- org.springframework.data:spring-data-commons:jar:1.12.5.RELEASE:compile
[INFO] | +- com.datastax.cassandra:cassandra-driver-dse:jar:2.1.7.1:compile
[INFO] | | \- com.datastax.cassandra:cassandra-driver-core:jar:2.1.7.1:compile
[INFO] | | +- io.netty:netty-handler:jar:4.0.27.Final:compile
[INFO] | | | +- io.netty:netty-buffer:jar:4.0.27.Final:compile
[INFO] | | | | \- io.netty:netty-common:jar:4.0.27.Final:compile
[INFO] | | | +- io.netty:netty-transport:jar:4.0.27.Final:compile
[INFO] | | | \- io.netty:netty-codec:jar:4.0.27.Final:compile
[INFO] | | \- com.codahale.metrics:metrics-core:jar:3.0.2:compile
[INFO] | \- org.slf4j:jcl-over-slf4j:jar:1.7.21:runtime
[INFO] +- org.springframework:spring-jdbc:jar:4.3.3.RELEASE:compile
[INFO] | \- org.springframework:spring-tx:jar:4.3.3.RELEASE:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.5:compile
[INFO] \- org.slf4j:slf4j-simple:jar:1.7.5:compile
Update: My logger is now working although I am unsure exactly what I did to make it work either of 2 things: 1) Under Project Structure->Artifacts tab, I clicked add new and added new artifact then deleted it OR 2) Restarted application and computer. Sorry I am unable to determine exactly what the solution was.
Related
I get the following message when I deploy my war to the Tomcat 7:
nested exception is java.lang.NoClassDefFoundError: javax/el/ELManager
I added <tomcat.version>7.0.61</tomcat.version> to my pom.xml and can now reproduce the error on my development environment.
The error happens after the bean creation, the other changes that were necessary to get the war to run I made.
I tried to change my pom.xml so that it uses old versions which might play nice with tomcat 7, but failed to remove the problem. I don't know which package produces the problem.
See pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.xxx</groupId>
<artifactId>monitormonitor</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>monitormonitor</name>
<description>Web Service Monitoring project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<start-class>com.xxx.monitormonitor.MonitormonitorApplication</start-class>
<!-- deploying war-file on tomcat 7 -->
<tomcat.version>7.0.61</tomcat.version><!-- nested exception is java.lang.NoClassDefFoundError: javax/el/ELManager -->
<servlet-api.version>3.0.1</servlet-api.version>
</properties>
<packaging>war</packaging>
<dependencies>
<!-- added other version of log4j for invalid byte tag error -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<!-- changed version vs. ClassFormatException: Invalid byte tag in constant pool: 19 -->
<!--<version>2.11.1</version>-->
<version>2.7</version>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- <scope>provided</scope> -->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<!--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>1.1.6.RELEASE</version>
<scope>provided</scope>
</dependency>
-->
<!-- added vs java.lang.NoClassDefFoundError: javax/el/ELManager -->
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
-->
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>2.2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.el</artifactId>
<version>2.2.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.xxx.monitormonitor.MonitormonitorApplication</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
dependency tree:
[INFO] com.xxx:monitormonitor:war:0.0.1-SNAPSHOT
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.7:compile
[INFO] +- org.apache.logging.log4j:log4j-core:jar:2.7:compile
[INFO] +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.1.2.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.1.2.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.1.2.RELEASE: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.apache.logging.log4j:log4j-to-slf4j:jar:2.11.1:compile
[INFO] | | | \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] | | \- org.yaml:snakeyaml:jar:1.23:runtime
[INFO] | +- com.zaxxer:HikariCP:jar:3.2.0:compile
[INFO] | | \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] | \- org.springframework:spring-jdbc:jar:5.1.4.RELEASE:compile
[INFO] | \- org.springframework:spring-tx:jar:5.1.4.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-mail:jar:2.1.2.RELEASE:compile
[INFO] | \- com.sun.mail:javax.mail:jar:1.6.2:compile
[INFO] | \- javax.activation:activation:jar:1.1:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.1.2.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.1.2.RELEASE:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.8:compile
[INFO] | | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] | | | \- com.fasterxml.jackson.core:jackson-core:jar:2.9.8:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.8:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.8:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.8:compile
[INFO] | +- org.hibernate.validator:hibernate-validator:jar:6.0.14.Final:compile
[INFO] | | +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] | | +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] | | \- com.fasterxml:classmate:jar:1.4.0:compile
[INFO] | +- org.springframework:spring-web:jar:5.1.4.RELEASE:compile
[INFO] | \- org.springframework:spring-webmvc:jar:5.1.4.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:5.1.4.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:5.1.4.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.1.2.RELEASE:provided
[INFO] | +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] | +- org.apache.tomcat.embed:tomcat-embed-core:jar:7.0.61:provided
[INFO] | +- org.apache.tomcat.embed:tomcat-embed-el:jar:7.0.61:provided
[INFO] | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:7.0.61:provided
[INFO] +- org.springframework.boot:spring-boot-devtools:jar:2.1.2.RELEASE:runtime
[INFO] | +- org.springframework.boot:spring-boot:jar:2.1.2.RELEASE:compile
[INFO] | \- org.springframework.boot:spring-boot-autoconfigure:jar:2.1.2.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.1.2.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:2.1.2.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.1.2.RELEASE:test
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.4.0:test
[INFO] | | \- net.minidev:json-smart:jar:2.3:test
[INFO] | | \- net.minidev:accessors-smart:jar:1.2:test
[INFO] | | \- org.ow2.asm:asm:jar:5.0.4:test
[INFO] | +- junit:junit:jar:4.12:test
[INFO] | +- org.assertj:assertj-core:jar:3.11.1:test
[INFO] | +- org.mockito:mockito-core:jar:2.23.4:test
[INFO] | | +- net.bytebuddy:byte-buddy:jar:1.9.7:test
[INFO] | | +- net.bytebuddy:byte-buddy-agent:jar:1.9.7:test
[INFO] | | \- org.objenesis:objenesis:jar:2.6:test
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] | +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] | +- org.springframework:spring-core:jar:5.1.4.RELEASE:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.1.4.RELEASE:compile
[INFO] | +- org.springframework:spring-test:jar:5.1.4.RELEASE:test
[INFO] | \- org.xmlunit:xmlunit-core:jar:2.6.2:test
[INFO] +- org.springframework:spring-context-support:jar:5.1.4.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:5.1.4.RELEASE:compile
[INFO] | \- org.springframework:spring-context:jar:5.1.4.RELEASE:compile
[INFO] +- javax.el:javax.el-api:jar:2.2.4:provided
[INFO] \- org.glassfish.web:javax.el:jar:2.2.4:provided
spring boot 2.1.2 release supports any Servlet 3.1+ compatible container.
Tomcat 7 is not one of them
spring boot docs
Use tomcat 8 or beyond http://tomcat.apache.org/whichversion.html
Spring Boot 2.1 requires a Servlet 3.1 compatible container. Tomcat 7 is a Servlet 3.0 container so you cannot use it with Spring Boot 2.1.
You'll need to upgrade to Tomcat 8.5.x or 9.0.x.
It is because javax/el/ELManager was introduced in el-api 3.0 and tomcat 7 is using el-api 2.2 so this class is not present in it.
Please make sure your dev and prod environment are the same when you are developing.
Or you can add following dependency in your pom.xml
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>3.0.0</version>
</dependency>
I'm trying to connect my Java web project to Firebase, so I'll be able to store my data in Firestore. I'm using Java Admin SDK, following official guide: FirebaseAdminSDK. Sadly, I'm getting exceptions when FirebaseAp is being initialized:
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V
at com.google.firebase.FirebaseApp.checkNotDeleted(FirebaseApp.java:352)
at com.google.firebase.FirebaseApp.getOptions(FirebaseApp.java:267)
at com.google.firebase.FirebaseApp$TokenRefresher.<init>(FirebaseApp.java:434)
at com.google.firebase.FirebaseApp$TokenRefresher$Factory.create(FirebaseApp.java:535)
at com.google.firebase.FirebaseApp.<init>(FirebaseApp.java:113)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:201)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:188)
Now, I read here and there, that it's problem with guava project and it is recommended to use different versions of guava library. I tried all versions starting from 18.
Then, I read that it can be caused by multiple guava libraries referenced by different libraries in my classpath in defferent versions fighting each other. So, I checked maven dependency tree to see if there are multiple dependencies on guava. Nope.
Then, I unpacked .WAR file to see what exact jars are being deployed to glassfish with my app. Only one guava jar is there (the one pointed by my pom.xml file).
To be honest, I've run out of ideas. Please help. You can see pom.xml and generated maven dependency tree appended below.
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.greenstudio</groupId>
<artifactId>trekking-project</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>trekking-project</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>5.6.0</version>
<exclusions>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>21.0</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.9</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
<version>2.5.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.3.3</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.6</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.3</version>
</dependency>
<dependency>
<groupId>primefaces.blacktie</groupId>
<artifactId>primefaces.blacktie</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>bootstrap</groupId>
<artifactId>bootstrap</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons.validator.routines.EmailValidatororg.apache.commons.validator.routines.EmailValidator</groupId>
<artifactId>org.apache.commons.validator.routines.EmailValidator</artifactId>
<version>1.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
dependency tree
[INFO] Scanning for projects...
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.8/maven-dependency-plugin-2.8.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.8/maven-dependency-plugin-2.8.pom (11 kB at 18 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.8/maven-dependency-plugin-2.8.jar
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.8/maven-dependency-plugin-2.8.jar (153 kB at 709 kB/s)
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building trekking-project 1.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for primefaces:primefaces:jar:5.3 is missing, no dependency information available
[WARNING] The POM for primefaces.blacktie:primefaces.blacktie:jar:1.0 is missing, no dependency information available
[WARNING] The POM for bootstrap:bootstrap:jar:1.0 is missing, no dependency information available
[WARNING] The POM for org.apache.commons.validator.routines.EmailValidatororg.apache.commons.validator.routines.EmailValidator:org.apache.commons.validator.routines.EmailValidator:jar:1.0 is missing, no dependency information available
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # trekking-project ---
Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-archiver/2.3/plexus-archiver-2.3.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-archiver/2.3/plexus-archiver-2.3.pom (3.4 kB at 38 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-dependency-analyzer/1.4/maven-dependency-analyzer-1.4.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-dependency-analyzer/1.4/maven-dependency-analyzer-1.4.pom (5.2 kB at 58 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-archiver/2.3/plexus-archiver-2.3.jar
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-dependency-analyzer/1.4/maven-dependency-analyzer-1.4.jar
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-dependency-analyzer/1.4/maven-dependency-analyzer-1.4.jar (27 kB at 105 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-archiver/2.3/plexus-archiver-2.3.jar (186 kB at 704 kB/s)
[INFO] com.greenstudio:trekking-project:war:1.0
[INFO] +- com.google.firebase:firebase-admin:jar:5.6.0:compile
[INFO] | +- com.google.api-client:google-api-client:jar:1.22.0:compile
[INFO] | | +- com.google.oauth-client:google-oauth-client:jar:1.22.0:compile
[INFO] | | \- com.google.http-client:google-http-client-jackson2:jar:1.22.0:compile
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.1.3:compile
[INFO] | +- com.google.api-client:google-api-client-gson:jar:1.22.0:compile
[INFO] | | \- com.google.http-client:google-http-client-gson:jar:1.22.0:compile
[INFO] | | \- com.google.code.gson:gson:jar:2.1:compile
[INFO] | +- com.google.http-client:google-http-client:jar:1.22.0:compile
[INFO] | | \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] | +- com.google.api:api-common:jar:1.2.0:compile
[INFO] | +- com.google.auth:google-auth-library-oauth2-http:jar:0.8.0:compile
[INFO] | | \- com.google.auth:google-auth-library-credentials:jar:0.8.0:compile
[INFO] | +- com.google.cloud:google-cloud-storage:jar:1.7.0:compile
[INFO] | | +- com.google.cloud:google-cloud-core:jar:1.7.0:compile
[INFO] | | | +- com.google.api:gax:jar:1.8.1:compile
[INFO] | | | +- com.google.protobuf:protobuf-java-util:jar:3.3.1:compile
[INFO] | | | +- com.google.api.grpc:proto-google-common-protos:jar:0.1.20:compile
[INFO] | | | \- com.google.api.grpc:proto-google-iam-v1:jar:0.1.20:compile
[INFO] | | +- com.google.cloud:google-cloud-core-http:jar:1.7.0:compile
[INFO] | | | +- com.google.http-client:google-http-client-appengine:jar:1.22.0:compile
[INFO] | | | \- com.google.http-client:google-http-client-jackson:jar:1.22.0:compile
[INFO] | | | \- org.codehaus.jackson:jackson-core-asl:jar:1.9.11:compile
[INFO] | | \- com.google.apis:google-api-services-storage:jar:v1-rev108-1.22.0:compile
[INFO] | +- com.google.cloud:google-cloud-firestore:jar:0.25.0-beta:compile
[INFO] | | +- io.netty:netty-tcnative-boringssl-static:jar:2.0.3.Final:compile
[INFO] | | +- com.google.cloud:google-cloud-core-grpc:jar:1.7.0:compile
[INFO] | | | +- com.google.protobuf:protobuf-java:jar:3.3.1:compile
[INFO] | | | +- io.grpc:grpc-protobuf:jar:1.6.1:compile
[INFO] | | | | \- io.grpc:grpc-protobuf-lite:jar:1.6.1:compile
[INFO] | | | \- io.grpc:grpc-context:jar:1.6.1:compile
[INFO] | | +- com.google.api:gax-grpc:jar:0.25.1:compile
[INFO] | | | +- com.google.auto.value:auto-value:jar:1.2:compile
[INFO] | | | \- org.threeten:threetenbp:jar:1.3.3:compile
[INFO] | | +- com.google.api.grpc:proto-google-cloud-firestore-v1beta1:jar:0.1.20:compile
[INFO] | | +- io.grpc:grpc-netty:jar:1.6.1:compile
[INFO] | | | +- io.grpc:grpc-core:jar:1.6.1:compile (version selected from constraint [1.6.1,1.6.1])
[INFO] | | | | +- com.google.errorprone:error_prone_annotations:jar:2.0.19:compile
[INFO] | | | | +- com.google.instrumentation:instrumentation-api:jar:0.4.3:compile
[INFO] | | | | \- io.opencensus:opencensus-api:jar:0.5.1:compile
[INFO] | | | +- io.netty:netty-codec-http2:jar:4.1.14.Final:compile (version selected from constraint [4.1.14.Final,4.1.14.Final])
[INFO] | | | \- io.netty:netty-handler-proxy:jar:4.1.14.Final:compile
[INFO] | | | \- io.netty:netty-codec-socks:jar:4.1.14.Final:compile
[INFO] | | +- io.grpc:grpc-stub:jar:1.6.1:compile
[INFO] | | \- io.grpc:grpc-auth:jar:1.6.1:compile
[INFO] | +- org.json:json:jar:20160810:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] | +- io.netty:netty-codec-http:jar:4.1.14.Final:compile
[INFO] | | \- io.netty:netty-codec:jar:4.1.14.Final:compile
[INFO] | +- io.netty:netty-handler:jar:4.1.14.Final:compile
[INFO] | | \- io.netty:netty-buffer:jar:4.1.14.Final:compile
[INFO] | | \- io.netty:netty-common:jar:4.1.14.Final:compile
[INFO] | \- io.netty:netty-transport:jar:4.1.14.Final:compile
[INFO] | \- io.netty:netty-resolver:jar:4.1.14.Final:compile
[INFO] +- com.google.guava:guava:jar:21.0:compile
[INFO] +- joda-time:joda-time:jar:2.9.9:compile
[INFO] +- org.eclipse.persistence:eclipselink:jar:2.5.2:provided
[INFO] | +- org.eclipse.persistence:javax.persistence:jar:2.1.0:provided
[INFO] | \- org.eclipse.persistence:commonj.sdo:jar:2.1.1:provided
[INFO] +- org.eclipse.persistence:org.eclipse.persistence.jpa.modelgen.processor:jar:2.5.2:provided
[INFO] | +- org.eclipse.persistence:org.eclipse.persistence.core:jar:2.5.2:provided
[INFO] | | \- org.eclipse.persistence:org.eclipse.persistence.asm:jar:2.5.2:provided
[INFO] | \- org.eclipse.persistence:org.eclipse.persistence.jpa:jar:2.5.2:provided
[INFO] | +- org.eclipse.persistence:org.eclipse.persistence.antlr:jar:2.5.2:provided
[INFO] | \- org.eclipse.persistence:org.eclipse.persistence.jpa.jpql:jar:2.5.2:provided
[INFO] +- org.apache.httpcomponents:httpcore:jar:4.3.3:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.3.6:compile
[INFO] | +- commons-logging:commons-logging:jar:1.1.3:compile
[INFO] | \- commons-codec:commons-codec:jar:1.6:compile
[INFO] +- primefaces:primefaces:jar:5.3:compile
[INFO] +- primefaces.blacktie:primefaces.blacktie:jar:1.0:compile
[INFO] +- bootstrap:bootstrap:jar:1.0:compile
[INFO] +- org.apache.commons.validator.routines.EmailValidatororg.apache.commons.validator.routines.EmailValidator:org.apache.commons.validator.routines.EmailValidator:jar:1.0:compile
[INFO] \- javax:javaee-web-api:jar:7.0:provided
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.897 s
[INFO] Finished at: 2018-01-12T10:16:59+01:00
[INFO] Final Memory: 15M/215M
[INFO] ------------------------------------------------------------------------
I even downloaded github repository of google firebase sdk and got rid of all guava code references there, but then I'm getting similar errors when trying to read/write Firestore. It seems that some other google libraries depend on that crappy little jar as well.
I had the same problem with Guava versions in different dependencies.
I resolved this in Gradle like this :
configurations.all {
resolutionStrategy {
force 'com.google.guava:guava:17.0'
}
}
There should be a Maven way, otherwise exclude Guava from all your dependencies and add it explicitly with your version.
It enforces Guava version globally. Fortunatelly for me, version 17 was compatible with all my dependencies. Neither 16- nor 18+ were... Sad thing these are using Guava.
Hope it helps,
Regards
I am trying to deploy a WAR file to a Glassfish 4.1 server.
During an attempt at deployment, I receive the following exception :
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.NoSuchMethodError: org.apache.logging.log4j.core.lookup.MapLookup.toMap(Ljava/util/List;)Ljava/util/Map;
Looking in the javadoc, I indeed can't see any toMap method ? (https://logging.apache.org/log4j/2.0/log4j-core/apidocs/org/apache/logging/log4j/core/lookup/MapLookup.html)
jar tvf on the war file :
WEB-INF/lib/log4j-core-2.1.jar
WEB-INF/lib/javax.inject-2.4.0-b06.jar
WEB-INF/lib/postgresql-9.3-1102-jdbc41.jar
WEB-INF/lib/javax.annotation-api-1.2.jar
WEB-INF/lib/javassist-3.18.1-GA.jar
WEB-INF/lib/jersey-common-2.15.jar
WEB-INF/lib/hk2-api-2.4.0-b06.jar
WEB-INF/lib/validation-api-1.1.0.Final.jar
WEB-INF/lib/jersey-container-servlet-core-2.15.jar
WEB-INF/lib/hk2-locator-2.4.0-b06.jar
WEB-INF/lib/log4j-web-2.0.2.jar
WEB-INF/lib/log4j-core-2.0.2.jar
WEB-INF/lib/jersey-client-2.15.jar
WEB-INF/lib/hk2-utils-2.4.0-b06.jar
WEB-INF/lib/javax.ws.rs-api-2.0.1.jar
WEB-INF/lib/aopalliance-repackaged-2.4.0-b06.jar
WEB-INF/lib/commons-lang3-3.3.2.jar
WEB-INF/lib/osgi-resource-locator-1.0.1.jar
WEB-INF/lib/log4j-api-2.1.jar
WEB-INF/lib/log4j-api-2.0.2.jar
WEB-INF/lib/jersey-guava-2.15.jar
WEB-INF/lib/jersey-server-2.15.jar
WEB-INF/lib/log4j-web-2.1.jar
WEB-INF/lib/commons-codec-1.10.jar
My pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>WebTool</groupId>
<artifactId>WebTool</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>WebTool</name>
<build>
<finalName>WebTool</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- my -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
<!--
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
-->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-bom</artifactId>
<version>${log4j.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<!-- <dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<version>${log4j.version}</version>
</dependency>-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commonslang.version}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${commonscodec.version}</version>
</dependency>
<!-- end my -->
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
</dependency>
<!-- uncomment this to get JSON support
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
</dependency>
-->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<!-- <version>${postgresql.version}</version> -->
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<!-- <version>${log4j.version}</version> -->
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<!-- <version>${log4j.version}</version> -->
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<!-- <version>${log4j.version}</version> -->
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<!-- <version>${commonslang.version}</version> -->
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<!-- <version>${commonscodec.version}</version> -->
</dependency>
<!-- configure connection pool in glassfish admin ! JDBC Connection Pool and JCBC Resource -->
</dependencies>
<!--
DEPENDENCY MANAGEMENT
-->
<properties>
<postgresql.version>9.3-1102-jdbc41</postgresql.version>
<jersey.version>2.15</jersey.version>
<log4j.version>2.1</log4j.version>
<dbcp2.version>2.0.1</dbcp2.version>
<commonslang.version>3.3.2</commonslang.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<commonscodec.version>1.10</commonscodec.version>
</properties>
Dependency tree:
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # WebTool ---
[INFO] WebTool:WebTool:war:1.0-SNAPSHOT
[INFO] +- org.glassfish.jersey.containers:jersey-container-servlet-core:jar:2.15:compile
[INFO] | +- org.glassfish.hk2.external:javax.inject:jar:2.4.0-b06:compile
[INFO] | +- org.glassfish.jersey.core:jersey-common:jar:2.15:compile
[INFO] | | +- (javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile - omitted for duplicate)
[INFO] | | +- javax.annotation:javax.annotation-api:jar:1.2:compile
[INFO] | | +- org.glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.15:compile
[INFO] | | +- org.glassfish.hk2:hk2-api:jar:2.4.0-b06:compile
[INFO] | | | +- org.glassfish.hk2:hk2-utils:jar:2.4.0-b06:compile
[INFO] | | | \- org.glassfish.hk2.external:aopalliance-repackaged:jar:2.4.0-b06:compile
[INFO] | | +- (org.glassfish.hk2.external:javax.inject:jar:2.4.0-b06:compile - omitted for duplicate)
[INFO] | | +- org.glassfish.hk2:hk2-locator:jar:2.4.0-b06:compile
[INFO] | | | +- (org.glassfish.hk2.external:javax.inject:jar:2.4.0-b06:compile - omitted for duplicate)
[INFO] | | | +- (org.glassfish.hk2.external:aopalliance-repackaged:jar:2.4.0-b06:compile - omitted for duplicate)
[INFO] | | | +- (org.glassfish.hk2:hk2-api:jar:2.4.0-b06:compile - omitted for duplicate)
[INFO] | | | +- (org.glassfish.hk2:hk2-utils:jar:2.4.0-b06:compile - omitted for duplicate)
[INFO] | | | \- org.javassist:javassist:jar:3.18.1-GA:compile
[INFO] | | \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile
[INFO] | +- org.glassfish.jersey.core:jersey-server:jar:2.15:compile
[INFO] | | +- (org.glassfish.jersey.core:jersey-common:jar:2.15:compile - omitted for duplicate)
[INFO] | | +- org.glassfish.jersey.core:jersey-client:jar:2.15:compile
[INFO] | | | +- (org.glassfish.jersey.core:jersey-common:jar:2.15:compile - omitted for duplicate)
[INFO] | | | +- (javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile - omitted for duplicate)
[INFO] | | | +- (org.glassfish.hk2:hk2-api:jar:2.4.0-b06:compile - omitted for duplicate)
[INFO] | | | +- (org.glassfish.hk2.external:javax.inject:jar:2.4.0-b06:compile - omitted for duplicate)
[INFO] | | | \- (org.glassfish.hk2:hk2-locator:jar:2.4.0-b06:compile - omitted for duplicate)
[INFO] | | +- (javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile - omitted for duplicate)
[INFO] | | +- (javax.annotation:javax.annotation-api:jar:1.2:compile - omitted for duplicate)
[INFO] | | +- (org.glassfish.hk2:hk2-api:jar:2.4.0-b06:compile - omitted for duplicate)
[INFO] | | +- (org.glassfish.hk2.external:javax.inject:jar:2.4.0-b06:compile - omitted for duplicate)
[INFO] | | +- (org.glassfish.hk2:hk2-locator:jar:2.4.0-b06:compile - omitted for duplicate)
[INFO] | | \- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] | \- javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile
[INFO] +- org.postgresql:postgresql:jar:9.3-1102-jdbc41:compile
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.1:compile
[INFO] +- org.apache.logging.log4j:log4j-core:jar:2.1:compile
[INFO] | \- (org.apache.logging.log4j:log4j-api:jar:2.1:compile - omitted for duplicate)
[INFO] +- org.apache.logging.log4j:log4j-web:jar:2.1:compile
[INFO] | +- (org.apache.logging.log4j:log4j-api:jar:2.1:compile - omitted for duplicate)
[INFO] | \- (org.apache.logging.log4j:log4j-core:jar:2.1:compile - omitted for duplicate)
[INFO] +- org.apache.commons:commons-lang3:jar:3.3.2:compile
[INFO] \- commons-codec:commons-codec:jar:1.10:compile
You have multiple versions of log4j version 2 in your WAR file, one you specified, and one - most likely - pulled in as a transitive dependency. Normally only the latest should be selected, but it may be a repackaged version.
Hence you need to identify where the one you do not want, comes from so you can figure out what to do with it. You can see the dependency tree with
mvn dependency:tree
See http://maven.apache.org/plugins/maven-dependency-plugin/usage.html for usage information.
Note that if you use Eclipse with m2e, just select the correct panel when having pom.xml open.
You then need to figure out what to do with it when you find out where it comes from. You most likely just want to exclude it (as you have a newer) - see http://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html for instructions. I would suggest you read it carefully so you understand what you are doing - this is essentially brain washing Maven because you know better.
I have a EAR with a number of EJB dependencies. 1 of these have a provided scope dependency:
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
<scope>provided</scope>
</dependency>
but inside the jar there is the jar mail-1.4.3.jar (I dependency i previously deleted)
I've tried with:
mvn eclipse:clean
mvn dependency:tree
mvn dependency:analyze-only
but there is no way to get rid if this jar, that cause me a `java.lang.ClassCastException: javax.mail.Session cannot be cast to javax.mail.Session in the server
Here the full pom.xml:
<!--
~ Copyright 2010-2012, CloudBees Inc.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>localdomain.localhost</groupId>
<artifactId>myApp</artifactId>
<packaging>war</packaging>
<version>1.0.2-SNAPSHOT</version>
<name>conFloorApp</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.2.8.RELEASE</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>javax.servlet.jsp.jstl-api</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<!-- Apache JSTL implementation -->
<groupId>org.glassfish.web</groupId>
<artifactId>javax.servlet.jsp.jstl</artifactId>
<version>1.2.2</version>
<exclusions>
<exclusion>
<!--
use javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api, exclude this one
-->
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<!-- used for the troubleshooting jsp datasource-mysql.jsp -->
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.27</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>3.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.3.Final</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.8.4.5</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-aspects</artifactId>
<version>3.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.maxmind.geoip</groupId>
<artifactId>geoip-api</artifactId>
<version>1.2.11</version>
</dependency>
<dependency>
<groupId>com.github.dandelion</groupId>
<artifactId>datatables-jsp</artifactId>
<version>0.9.3</version>
</dependency>
</dependencies>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav</artifactId>
<version>1.0-beta-2</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<scm>
<connection>scm:git:https://github.com/CloudBees-community/tomcat7-maven-clickstart.git</connection>
<tag>HEAD</tag>
</scm>
<distributionManagement>
<repository>
<id>community-release</id>
<url>dav:https://repository-community.forge.cloudbees.com/release/</url>
</repository>
<snapshotRepository>
<id>community-snapshot</id>
<url>dav:https://repository-community.forge.cloudbees.com/snapshot/</url>
</snapshotRepository>
</distributionManagement>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
</project>
You are looking in the wrong spot. Here is the dependency tree for your pom. As per the dependency tree this pom is not pulling mail.jar you need to elsewhere. look at some other projects that may be pulling mail.jar as their dependency.
Command to check dependency tree
mvn dependency:tree -Dverbose
Note there is only one entry of mail.jar that is marked as provided so this pom is not a issue
[INFO] +- javax.mail:mail:jar:1.4:provided
[INFO] | \- javax.activation:activation:jar:1.1:provided
Complete Output of dependency tree
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building conFloorApp 1.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) # myApp ---
[INFO] localdomain.localhost:myApp:war:1.0.2-SNAPSHOT
[INFO] +- junit:junit:jar:4.8.1:test (scope not updated to compile)
[INFO] +- org.mockito:mockito-all:jar:1.8.4:compile
[INFO] +- org.springframework:spring-test:jar:3.2.8.RELEASE:test
[INFO] | \- (org.springframework:spring-core:jar:3.2.8.RELEASE:compile - scope updated from test; omitted for duplicate)
[INFO] +- javax.servlet:javax.servlet-api:jar:3.0.1:provided
[INFO] +- javax.servlet.jsp:javax.servlet.jsp-api:jar:2.2.1:provided
[INFO] +- javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api:jar:1.2.1:compile
[INFO] +- org.glassfish.web:javax.servlet.jsp.jstl:jar:1.2.2:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.27:provided
[INFO] +- org.springframework:spring-context:jar:3.2.8.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:3.2.8.RELEASE:compile
[INFO] | | +- (aopalliance:aopalliance:jar:1.0:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-beans:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | | \- (org.springframework:spring-core:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | +- org.springframework:spring-beans:jar:3.2.8.RELEASE:compile
[INFO] | | \- (org.springframework:spring-core:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-core:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | \- org.springframework:spring-expression:jar:3.2.8.RELEASE:compile
[INFO] | \- (org.springframework:spring-core:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] +- org.springframework:spring-core:jar:3.2.8.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.1.3:compile
[INFO] +- org.springframework:spring-web:jar:3.2.8.RELEASE:compile
[INFO] | +- (org.springframework:spring-aop:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-beans:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-context:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | \- (org.springframework:spring-core:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] +- org.springframework:spring-webmvc:jar:3.2.8.RELEASE:compile
[INFO] | +- (org.springframework:spring-beans:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-context:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-core:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-expression:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | \- (org.springframework:spring-web:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] +- org.springframework:spring-orm:jar:3.2.8.RELEASE:compile
[INFO] | +- (org.springframework:spring-beans:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-core:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-jdbc:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | \- org.springframework:spring-tx:jar:3.2.8.RELEASE:compile
[INFO] | +- (org.springframework:spring-beans:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | \- (org.springframework:spring-core:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] +- org.hibernate:hibernate-core:jar:3.6.3.Final:compile
[INFO] | +- antlr:antlr:jar:2.7.6:compile
[INFO] | +- commons-collections:commons-collections:jar:3.1:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | +- org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile
[INFO] | | \- (org.slf4j:slf4j-api:jar:1.5.8:compile - omitted for conflict with 1.6.1)
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final:compile
[INFO] | +- javax.transaction:jta:jar:1.1:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.6.1:compile
[INFO] +- org.springframework:spring-jdbc:jar:3.2.8.RELEASE:compile
[INFO] | +- (org.springframework:spring-beans:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-core:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | \- (org.springframework:spring-tx:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] +- javassist:javassist:jar:3.12.1.GA:compile
[INFO] +- c3p0:c3p0:jar:0.8.4.5:compile
[INFO] +- cglib:cglib:jar:2.2:compile
[INFO] | \- asm:asm:jar:3.1:compile
[INFO] +- org.springframework.security:spring-security-web:jar:3.2.3.RELEASE:compile
[INFO] | +- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework.security:spring-security-core:jar:3.2.3.RELEASE:compile
[INFO] | | +- (aopalliance:aopalliance:jar:1.0:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-aop:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-beans:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-context:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-core:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | | \- (org.springframework:spring-expression:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-beans:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-context:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-core:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-expression:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | \- (org.springframework:spring-web:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] +- org.springframework.security:spring-security-config:jar:3.2.3.RELEASE:compile
[INFO] | +- (aopalliance:aopalliance:jar:1.0:compile - omitted for duplicate)
[INFO] | +- (org.springframework.security:spring-security-core:jar:3.2.3.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-aop:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-beans:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-context:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | \- (org.springframework:spring-core:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] +- org.springframework.security:spring-security-aspects:jar:3.2.3.RELEASE:compile
[INFO] | +- (org.springframework.security:spring-security-core:jar:3.2.3.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-beans:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-context:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] | \- (org.springframework:spring-core:jar:3.2.8.RELEASE:compile - omitted for duplicate)
[INFO] +- javax.mail:mail:jar:1.4:provided
[INFO] | \- javax.activation:activation:jar:1.1:provided
[INFO] +- com.maxmind.geoip:geoip-api:jar:1.2.11:compile
[INFO] \- com.github.dandelion:datatables-jsp:jar:0.9.3:compile
[INFO] +- com.github.dandelion:datatables-core:jar:0.9.3:compile
[INFO] | +- com.googlecode.json-simple:json-simple:jar:1.1.1:compile
[INFO] | | \- (junit:junit:jar:4.10:compile - omitted for conflict with 4.8.1)
[INFO] | +- commons-beanutils:commons-beanutils:jar:1.8.3:compile
[INFO] | \- (org.slf4j:slf4j-api:jar:1.7.5:compile - omitted for conflict with 1.6.1)
[INFO] \- (org.slf4j:slf4j-api:jar:1.7.5:compile - omitted for conflict with 1.6.1)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.611s
[INFO] Finished at: Fri May 23 21:55:07 EDT 2014
[INFO] Final Memory: 10M/245M
[INFO] ------------------------------------------------------------------------
Having this dependencies section in my pom.xml:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.7.1</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.7.1</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.7.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.26</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.2.6.Final</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-api</artifactId>
<version>2.7.1</version>
<exclusions>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-javamail_1.4_spec</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.7.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
I expected the geronimo-javamail_1.4_spec package to be excluded from the build and, indeed, when I run mvn dependency:tree, it is no longer listed there.
However, when running the resulting jar, the JarClassLoader still complains about javax/mail classes being hidden by the geronimo ones...
Sure enough, when I examine the jar via 7-zip, I see that geronimo-javamail_1.4_spec-1.7.1.jar is still there (comes as part of the org.apache.cxf:cxf-api:jar:2.7.1:compile package).
How do I fully exclude a package? i.e. not only remove it from the dependency tree, but also not include it at all in the resulting jar?
Adding the onejar relevant xml per the comment below:
<plugin>
<groupId>com.jolira</groupId>
<artifactId>onejar-maven-plugin</artifactId>
<version>1.4.4</version>
<executions>
<execution>
<configuration>
<mainClass>com.corp.dept.proj.myclient</mainClass>
<onejarVersion>0.97</onejarVersion>
<attachToBuild>true</attachToBuild>
<!-- Optional, default is "onejar" -->
<classifier>onejar</classifier>
</configuration>
<goals>
<goal>one-jar</goal>
</goals>
</execution>
</executions>
</plugin>
Adding the output of the mvn dependency after the scope & debug options were specified per the answer below:
C:\Users\withheld\workspace\myclient>mvn dependency:tree -Dscope=runtime -Ddebug=true
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'dependency'.
[INFO] org.apache.maven.plugins: checking for updates from onejar-maven-plugin.googlecode.com
[INFO] org.codehaus.mojo: checking for updates from onejar-maven-plugin.googlecode.com
[INFO] ------------------------------------------------------------------------
[INFO] Building myclient
[INFO] task-segment: [dependency:tree]
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/com/oracle/ojdbc14/14/ojdbc14-14.pom
[INFO] Unable to find resource 'com.oracle:ojdbc14:pom:14' in repository central (http://repo1.maven.org/maven2)
[INFO] [dependency:tree {execution: default-cli}]
[INFO] com.corp.dept.proj:myclient:jar:0.0.6
[INFO] +- junit:junit:jar:3.8.1:test
[INFO] +- com.oracle:ojdbc14:jar:14:compile
[INFO] +- org.apache.cxf:cxf-rt-frontend-jaxws:jar:2.7.1:runtime
[INFO] | +- xml-resolver:xml-resolver:jar:1.2:runtime
[INFO] | +- asm:asm:jar:3.3.1:runtime
[INFO] | +- org.apache.cxf:cxf-rt-bindings-soap:jar:2.7.1:runtime
[INFO] | | \- org.apache.cxf:cxf-rt-databinding-jaxb:jar:2.7.1:runtime
[INFO] | +- org.apache.cxf:cxf-rt-bindings-xml:jar:2.7.1:runtime
[INFO] | +- org.apache.cxf:cxf-rt-frontend-simple:jar:2.7.1:runtime
[INFO] | \- org.apache.cxf:cxf-rt-ws-addr:jar:2.7.1:runtime
[INFO] | \- org.apache.cxf:cxf-rt-ws-policy:jar:2.7.1:runtime
[INFO] | \- org.apache.neethi:neethi:jar:3.0.2:runtime
[INFO] +- org.apache.cxf:cxf-rt-transports-http:jar:2.7.1:compile
[INFO] | \- org.apache.cxf:cxf-rt-core:jar:2.7.1:compile
[INFO] | \- com.sun.xml.bind:jaxb-impl:jar:2.1.13:compile
[INFO] +- org.springframework:spring-web:jar:3.0.7.RELEASE:compile
[INFO] | +- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework:spring-beans:jar:3.0.7.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:3.0.7.RELEASE:compile
[INFO] | | +- org.springframework:spring-aop:jar:3.0.7.RELEASE:compile
[INFO] | | +- org.springframework:spring-expression:jar:3.0.7.RELEASE:compile
[INFO] | | \- org.springframework:spring-asm:jar:3.0.7.RELEASE:compile
[INFO] | \- org.springframework:spring-core:jar:3.0.7.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.26:compile
[INFO] +- org.hibernate:hibernate-core:jar:4.2.6.Final:compile
[INFO] | +- antlr:antlr:jar:2.7.7:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.1.0.GA:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.1.Final:compile
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
[INFO] | +- org.hibernate.common:hibernate-commons-annotations:jar:4.0.2.Final:compile
[INFO] | \- org.javassist:javassist:jar:3.15.0-GA:compile
[INFO] +- org.apache.cxf:cxf-api:jar:2.7.1:compile
[INFO] | +- org.codehaus.woodstox:woodstox-core-asl:jar:4.1.4:runtime
[INFO] | | \- org.codehaus.woodstox:stax2-api:jar:3.1.1:runtime
[INFO] | +- org.apache.ws.xmlschema:xmlschema-core:jar:2.0.3:compile
[INFO] | \- wsdl4j:wsdl4j:jar:1.6.2:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:compile
[INFO] +- javax.mail:mail:jar:1.4.1:compile
[INFO] \- javax.activation:activation:jar:1.1.1:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4 seconds
[INFO] Finished at: Thu Apr 24 11:22:49 EDT 2014
[INFO] Final Memory: 20M/49M
[INFO] ------------------------------------------------------------------------
The onejar plugin adds all artifacts from maven's runtime scope, as it should be.
The command mvn dependency:tree does not seem to list all runtime dependencies properly though. Could be a bug, I don't know why.
Luckily, by adding a few parameters you can have all runtime scope dependencies listed.
mvn dependency:tree -Dscope=runtime -Ddebug=true
This will show that cxf-rt-core also has geronimo-javamail as dependency. So, your solution would be to explicitly add the core jar with an exclusion to your dependencies.
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-core</artifactId>
<version>2.7.1</version>
<exclusions>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-javamail_1.4_spec</artifactId>
</exclusion>
</exclusions>
</dependency>