I am building a Java Maven Project and I have a dependency "net.minidev.json-smart:2.3-SNAPSHOT" imported in my package hbase 2.4.9 with another dependency and this displays a warning and Jenkins takes 1 or 2 minutes to resolve only this dependency.
the dependency tree is the following :
org.apache.hbase:hbase-server:2.4.9 -> org.apache.hadoop:hadoop-auth:2.10 -> com.nimbusds:nimbus-jose-jwt:4.41.1 -> net.minidev:json-smart:2.3-SNAPSHOT)
But when I exclude hadoop-auth 2.10 to use latest ...
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-server</artifactId>
<version>2.4.9</version>
<exclusions>
<exclusion>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-auth</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-auth</artifactId>
<version>3.3.2</version>
</dependency>
I have this dependency-tree:
[INFO] +- org.apache.hadoop:hadoop-auth:jar:3.3.2:compile
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
[INFO] | | \- org.apache.httpcomponents:httpcore:jar:4.4.13:compile
[INFO] | +- com.nimbusds:nimbus-jose-jwt:jar:9.8.1:compile
[INFO] | | \- com.github.stephenc.jcip:jcip-annotations:jar:1.0-1:compile
[INFO] | +- net.minidev:json-smart:jar:2.4.7:compile
[INFO] | | \- net.minidev:accessors-smart:jar:2.4.7:compile
[INFO] | | \- org.ow2.asm:asm:jar:9.1:compile
and when I build with mvn -U clean install I have this message:
[WARNING] The POM for net.minidev:json-smart:jar:2.3-SNAPSHOT is missing, no dependency information available
The debug logs do not say anything more
how can I completely remove it ?
Thanks a lot for your help
In my project, we had to exclude com.nimbusds:nimbus-jose-jwt from hadoop-auth because of an odd transitive dependency. This ticket: https://issues.apache.org/jira/browse/HADOOP-14903 appears to relate to the problem. We are not using this updated version. Based on your error, maybe this "fix" didn't work.
I'm attempting to display the full tree of dependencies for a project I'm working on using the maven-dependency-plugin version 3.1.2 from the command line, but the mvn dependency:tree goal (nor any of the other goals from the maven-dependency-plugin) is not showing the test dependencies. The documentation of the plugin (https://maven.apache.org/plugins/maven-dependency-plugin/tree-mojo.html) states that all scopes are included by default, so using the -Dscope=test shouldn't be necessary (but when adding this parameter, the output doesn't change).
I've run this with a clean .m2 repository, using no settings.xml file (to ensure that all artifacts are coming directly from repo.maven.apache.org).
I'm running using maven 3.6.2 on a linux environment (CentOS 7) and using Oracle Java 1.8.0_144
Here's my POM:
<?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.sw-eval</groupId>
<artifactId>cayenne-eval</artifactId>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne-server</artifactId>
<version>4.2.M2</version>
</dependency>
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne-di</artifactId>
<version>4.2.M2</version>
</dependency>
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne-dbsync</artifactId>
<version>4.2.M2</version>
</dependency>
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne-client</artifactId>
<version>4.2.M2</version>
</dependency>
</dependencies>
</project>
Here's the output I receive from running the command mvn dependency:tree:
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.sw-eval:cayenne-eval >----------------------
[INFO] Building cayenne-eval 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # cayenne-eval ---
[INFO] com.sw-eval:cayenne-eval:jar:1.0.0-SNAPSHOT
[INFO] +- org.apache.cayenne:cayenne-server:jar:4.2.M2:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- org.apache.cayenne:cayenne-di:jar:4.2.M2:compile
[INFO] +- org.apache.cayenne:cayenne-dbsync:jar:4.2.M2:compile
[INFO] | +- org.apache.cayenne:cayenne-project:jar:4.2.M2:compile
[INFO] | \- net.java.dev.inflector:inflector:jar:0.7.0:compile
[INFO] \- org.apache.cayenne:cayenne-client:jar:4.2.M2:compile
[INFO] +- com.caucho:hessian:jar:4.0.63:compile
[INFO] \- org.apache.cayenne:cayenne-rop-server:jar:4.2.M2:compile
[INFO] +- org.apache.cayenne:cayenne-web:jar:4.2.M2:compile
[INFO] \- org.slf4j:slf4j-simple:jar:1.7.25:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.951 s
[INFO] Finished at: 2020-11-25T08:53:17-07:00
[INFO] ------------------------------------------------------------------------
When referring to the cayenne-server pom, however, there are many dependencies marked as test which are not shown in the output (specifically, the following are direct dependencies of cayenne-server, see https://search.maven.org/artifact/org.apache.cayenne/cayenne-server/4.2.M2/jar):
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.cayenne.build-tools</groupId>
<artifactId>cayenne-test-utilities</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-mock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.mockrunner</groupId>
<artifactId>mockrunner-jdbc</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<!-- this one have old Xerces dependency that clashes with JDK's one -->
<groupId>nekohtml</groupId>
<artifactId>nekohtml</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<scope>test</scope>
</dependency>
So, is there something that I'm missing that needs to be enabled to show these test-scoped dependencies, and / or is this a weird artifact unique to the cayenne-server dependency?
Thanks in advance!
Dependencies of scope test are not transitive.
The test dependencies of your dependencies are not part of your dependency tree. They are ignored by Maven.
I have a project A, which has B and C dependencies.
The project B also depends on C.
In project A pom, I have:
<dependencyManagement>
<dependency>
<groupId>br.com.mygroup</groupId>
<artifactId>C</artifactId>
<version>2</version>
</dependency>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>br.com.mygroup</groupId>
<artifactId>B</artifactId>
<version>BVERSION</version>
</dependency>
<dependency>
<groupId>br.com.mygroup</groupId>
<artifactId>C</artifactId>
<version>2</version>
</dependency>
<dependencies>
In project B(version BVERSION), I have:
<dependencies>
<dependency>
<groupId>br.com.mygroup</groupId>
<artifactId>C</artifactId>
<version>1</version>
</dependency>
</dependencies>
I have added some methods in C dependency in version 2, but the code doesn't compile when I try to use the new methods. That is, I can't access the new methods. Project A is using version 1(which is inside project B) of C.
If I change the order of the import in project A pom from B, C to C, B, the code compiles, but at execution time a get java.lang.NoSuchMethodError error.
Shouldn't maven dependencyManagement deal with this problem and force project A to use version 2 of C? Does anyone have an idea of what I am getting wrong?
EDIT 1:
mvn dependency:tree returns the following:
[INFO] br.com.mygroup:A:1.0-SNAPSHOT
[INFO] +- br.com.mygroup:B:jar:BVERSION:compile
[INFO] +- br.com.mygroup:C:jar:2:compile
EDIT 2:
mvn dependency:list returns the following:
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< br.com.mygroup:A >---------------------
[INFO] Building A 1.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:list (default-cli) # A ---
[INFO]
[INFO] The following files have been resolved:
[INFO] br.com.mygroup:B:jar:BVERSION:compile
[INFO] br.com.mygroup:C:jar:2:compile
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.639 s
[INFO] Finished at: 2019-10-04T09:03:37-03:00
[INFO] ------------------------------------------------------------------------
I have a problem when I deploy a webapp with hibernate 5
Caused by: java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V
at org.hibernate.internal.NamedQueryRepository.checkNamedQueries(NamedQueryRepository.java:149) [hibernate-core-5.0.0.CR2.jar:5.0.0.CR2]
at org.hibernate.internal.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:759) [hibernate-core-5.0.0.CR2.jar:5.0.0.CR2]
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:490) [hibernate-core-5.0.0.CR2.jar:5.0.0.CR2]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444) [hibernate-core-5.0.0.CR2.jar:5.0.0.CR2]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:708) [hibernate-core-5.0.0.CR2.jar:5.0.0.CR2]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724) [hibernate-core-5.0.0.CR2.jar:5.0.0.CR2]
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:372) [spring-orm-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:454) [spring-orm-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:439) [spring-orm-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633) [spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570) [spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
... 23 more
With Hibernate 4 everything is OK.
I had a look at the class NamedQueryRepository at line 149. That class is calling the method debugf in this way
log.debugf( "Checking %s named HQL queries", namedQueryDefinitionMap.size() );
I can not see the problem
Here is my dependency tree
[INFO] ------------------------------------------------------------------------
[INFO] Building app Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # app---
[INFO] +- org.springframework:spring-aspects:jar:4.1.7.RELEASE:compile
[INFO] | \- org.aspectj:aspectjweaver:jar:1.8.6:compile
[INFO] +- org.springframework:spring-tx:jar:4.1.7.RELEASE:compile
[INFO] +- org.springframework:spring-beans:jar:4.1.7.RELEASE:compile
[INFO] +- org.springframework:spring-context-support:jar:4.1.7.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:4.1.7.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:4.1.7.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:4.1.7.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- org.springframework:spring-orm:jar:4.1.7.RELEASE:compile
[INFO] +- org.springframework:spring-web:jar:4.1.7.RELEASE:compile
[INFO] +- org.springframework:spring-aop:jar:4.1.7.RELEASE:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-jdbc:jar:4.1.7.RELEASE:compile
[INFO] +- org.springframework:spring-test:jar:4.1.7.RELEASE:test
[INFO] +- junit:junit:jar:4.12:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.hibernate:hibernate-entitymanager:jar:5.0.0.CR2:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] | +- org.hibernate:hibernate-core:jar:5.0.0.CR2:compile
[INFO] | | +- antlr:antlr:jar:2.7.7:compile
[INFO] | | \- org.jboss:jandex:jar:1.2.2.Final:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | | \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] | +- org.hibernate.common:hibernate-commons-annotations:jar:5.0.0.Final:compile
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] | +- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile
[INFO] | \- org.javassist:javassist:jar:3.18.1-GA:compile
[INFO] +- org.hibernate:hibernate-c3p0:jar:5.0.0.CR2:compile
[INFO] | \- com.mchange:c3p0:jar:0.9.2.1:compile
[INFO] | \- com.mchange:mchange-commons-java:jar:0.2.3.4:compile
[INFO] +- org.primefaces:primefaces:jar:5.2.RC3:compile
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.2:compile
[INFO] +- org.apache.logging.log4j:log4j-core:jar:2.2:compile
[INFO] \- net.sourceforge.jtds:jtds:jar:1.2.8:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
In glass fish This problem is caused by collision with dependencies of glassfish modules. If you check lib list in glassfishdir/modules you would see boss-logging.jar. You can delete it and replace with latest such as org.jboss.logging:jboss-logging:jar:3.3.0.Final. It worked for me.
In my case the culprit was the Jersey bean validator artifact.
One of its dependencies, bean-validation-2.4.0-b06.jar contains Jboss logging classes, for some reason.
I had to exclude the jersey-bean-validation and bean-validator artifacts from the spring-boot-starter-jersey dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
<exclusions>
<exclusion>
<artifactId>jersey-bean-validation</artifactId>
<groupId>org.glassfish.jersey.ext</groupId>
</exclusion>
<exclusion>
<artifactId>bean-validator</artifactId>
<groupId>org.glassfish.hk2.external</groupId>
</exclusion>
</exclusions>
</dependency>
EDIT: As of spring-boot 1.3.0, this is fixed and the exclusions above are not necessary anymore.
Try upgrading jboss-logging.jar to a more recent version. The one you are using does not seem to be compatible with Hibernate 5.
I also faced with such kind of problem when deployed ear on weblogic server.
Apparently, weblogic also use jboss logging system, and use old version of it.
My fix:
Add "weblogic-application.xml" to META-INF folder with this content:
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application>
<prefer-application-packages>
<package-name>org.jboss.logging.*</package-name>
</prefer-application-packages>
<prefer-application-resources>
<resource-name>org/jboss/logging/Logger.class</resource-name>
</prefer-application-resources>
</weblogic-application>
I was getting the same error using jersey-spring-3 and hibernate 5.0.1.Final.Excluding org.glassfish.hk2.external:bean-validator from jersy-spring-3 and adding org.glassfish.jersey.ext:jersey-bean-validation worked for me.Here is my final dependency.
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
<version>2.22.2</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>bean-validator</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-bean-validation</artifactId>
<version>2.22.2</version>
</dependency>
from :
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
<version>2.22.2</version>
</dependency>
In all probability you've got an outdated JBoss Logging JAR on the application's classpath. The ...f methods are a relatively new addition to the Logger API. Hibernate 5 directly depends on Logging version 3.3.0, but it is possible that somehwere in your pom.xml you have an overriding dependency to an earlier version. Another possibility is that you are deploying to a JBoss container where the logging API is container-provided. Then you may need to upgrade the JBoss server, or introduce a workaround to prefer classes contributed by your application.
Check my answer at NoSuchMethodError: org.jboss.logging.Logger.debugf
Even I was having issues after upgrading to Hibernate 5.2 , and the culprit was "jboss-logging 3.3.0.Final" which I see present in your dependencies too.
Following the steps on the link shared in the answer, you can reduce the dependency jboss-logging to 3.2 level which has the required function.
In my case the issue was caused by an older version of jboss-logging coming as transitive dependency from hibernate-ehcache, which I found by looking into the maven dependencies tree. I solved it by adding the exclusion:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>${hibernate.version}</version>
<exclusions>
<exclusion>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
I had the same error, it is solved by
First add the dependency of jboss logging jar as follows
<!-- https://mvnrepository.com/artifact/org.jboss.logging/jboss-logging -->
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.3.0.Final</version>
</dependency>
And if the error still exists then add following exlcusion to the maven dependency.
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
<version>2.12</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2</artifactId>
</exclusion>
</exclusions>
</dependency>
After doing these two things, it is working fine for me.I hope it will work for
you also.
Error that i got was "
Application run failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V
:::
:::
Caused by: java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V"
i deleted the jboss-logging folder <.m2\repository\org\jboss\logging\jboss-logging> and restarted the jboss server.
The jars got addedback and the error was gone. (i got some other error after that, but atleast this error was gone)
I too faced this issue. This is what fixed it for me
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.1.RELEASE</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
I have the same problen with spring4.2.1+hibernate5.0.2+jersey2.23.1.
My solution is the same: Excluding org.glassfish.hk2.external:bean-validator from jersy-spring-3 and adding org.glassfish.jersey.ext:jersey-bean-validation.
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
<version>2.23.1</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>bean-validator</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-bean-validation</artifactId>
<version>2.23.1</version>
</dependency>
In my product environment, just delete bean-validator-2.4.0-b34.jar and add jersey-bean-validation-2.23.1.jar
This can be caused if a dependency includes
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.6.2</version>
</dependency>
Exclude it using an exclusions element in dependency.
JBoss 6.1+??
I set org.jboss.logging for jboss-logging-3.3.0.Final-redhat-1.jar in modules of jboss.
Its works for me.
Att.,
You can use Eclipse to find out which jar is causing the problem:
Setup a project with all your jars on the classpath
Navigate -> Open Type...
Type in org.jboss.logging.Logger
This will give you a list of jars which include the class. One of these is out of date and needs to be excluded (refer to other answers for variations on this).
My error was caused by GlassFish and I fixed it by configuring glassfish-web.xml:
The Java Servlet specification recommends that a web module's class loader look in the local class loader before delegating to its parent. You can make this class loader follow the delegation inversion model in the Servlet specification by setting delegate="false" in the class-loader element of the glassfish-web.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
<context-root>/myContext</context-root>
<!–– Change this line "true" to "false" -->
<class-loader delegate="false"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
</glassfish-web-app>
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>