Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 3.0.4
-
Fix Version/s: None
-
Component/s: Dependencies
-
Labels:None
-
Environment:HideApache Maven 3.0.4 (r1232337; 2012-01-17 00:44:56-0800)
Maven home: D:\bin\apache-maven-3.0.4
Java version: 1.6.0_27, vendor: Sun Microsystems Inc.
Java home: D:\bin\java\jdk1.6.0_27\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"ShowApache Maven 3.0.4 (r1232337; 2012-01-17 00:44:56-0800) Maven home: D:\bin\apache-maven-3.0.4 Java version: 1.6.0_27, vendor: Sun Microsystems Inc. Java home: D:\bin\java\jdk1.6.0_27\jre Default locale: en_US, platform encoding: Cp1252 OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
-
Complexity:Intermediate
-
Number of attachments :1
Description
Expected: A dependency declared with a scope of 'provided', along with any transitive dependencies, should not be included in the final artifact.
Actual: I have a dependency, jsp-api, declared with 'provided' scope. This dependency has a dependency of its own, servlet-api. The servlet-api.jar is being included in the web-inf/lib folder of the resultant war file.
Background: We recently upgraded from Maven 2.2.1 to Maven 3.0.4. The problem was not witnessed until after the upgrade.
Steps to Reproduce: Run mvn install, then have a look at the web-inf/lib folder. Notice that the servlet-api.jar has been included.
Additional Info: It seems that I can only reproduce this behavior when declaring a specific dependency in my pom, spring-ldap. Here is the dependency tree for the given pared-down project (attached):
— maven-dependency-plugin:2.1:tree (default-cli) @ provided-scope-not-working —
com.bug.example:provided-scope-not-working:war:0.0.1-SNAPSHOT
+- javax.servlet:jsp-api:jar:2.0:provided
| - javax.servlet:servlet-api:jar:2.4:provided - org.springframework.ldap:spring-ldap:jar:1.2.1:compile +- commons-logging:commons-logging:jar:1.0.4:compile +- commons-lang:commons-lang:jar:2.1:compile +- org.springframework:spring-beans:jar:2.0.6:compile |
| +- (commons-logging:commons-logging:jar:1.1:compile - omitted for conflict with 1.0.4) |
| - (org.springframework:spring-core:jar:2.0.6:compile - omitted for duplicate) - org.springframework:spring-core:jar:2.0.6:compile - (commons-logging:commons-logging:jar:1.1:compile - omitted for conflict with 1.0.4) |
Issue Links
- is duplicated by
-
MNG-5273
Transitive dependencies with scope provided ending up in the final artifact
-
Activity
Note that the dependency plugin does not use the dependency resolution algorithm of M3 and might therefore not show the reality. For M3 you have to look at the debug output when starting Maven with -X option to be sure.
Ok here goes the details. We have this dependency as provided in the parent POM and the child pom just declares the groupid and artifactid.
<dependency>
<groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-tomcat</artifactId>
<version>5.0.1.GA</version>
<scope>provided</scope>
</dependency>
Ok now I ran the maven in the debug mode and put the output into the text file and here are the details. All of these below transitive dependencies of the above dependency we included are ending up in the final WAR WEB-INF/lib folder which should not be the case. There are lot of other jboss dependencies that are ending up as well.
+ WEB-INF/lib/jboss-security-spi-2.0.2.SP6.jar has been copied.
[DEBUG] Processing: jboss-deployment-spi-5.0.3.GA.jar
[DEBUG] + WEB-INF/lib/jboss-deployment-spi-5.0.3.GA.jar has been copied.
[DEBUG] Processing: jbosssx-client-2.0.2.SP6.jar
[DEBUG] + WEB-INF/lib/jbosssx-client-2.0.2.SP6.jar has been copied.
[DEBUG] Processing: jbossws-native-jaxws-3.0.5.GA.jar
[DEBUG] + WEB-INF/lib/jbossws-native-jaxws-3.0.5.GA.jar has been copied.
[DEBUG] Processing: jbossws-native-saaj-3.0.5.GA.jar
[DEBUG] + WEB-INF/lib/jbossws-native-saaj-3.0.5.GA.jar has been copied.
+ WEB-INF/lib/jboss-common-core-2.2.11.GA.jar has been copied.
[DEBUG] Processing: jboss-metadata-1.0.0.CR16.jar
[DEBUG] + WEB-INF/lib/jboss-metadata-1.0.0.CR16.jar has been copied.
[DEBUG] Processing: jboss-ejb3-ext-api-1.0.0.jar
[DEBUG] + WEB-INF/lib/jboss-ejb3-ext-api-1.0.0.jar has been copied.
[DEBUG] Processing: jboss-jms-api-1.1.0.GA.jar
[DEBUG] + WEB-INF/lib/jboss-jms-api-1.1.0.GA.jar has been copied.
[DEBUG] Processing: jboss-transaction-api-1.0.1.GA.jar
[DEBUG] + WEB-INF/lib/jboss-transaction-api-1.0.1.GA.jar has been copied.
[DEBUG] Processing: jboss-jaxws-3.0.1-native-2.0.4.GA.jar
[DEBUG] + WEB-INF/lib/jboss-jaxws-3.0.1-native-2.0.4.GA.jar has been copied.
[DEBUG] Processing: jboss-mdr-2.0.0.GA.jar
[DEBUG] + WEB-INF/lib/jboss-mdr-2.0.0.GA.jar has been copied.
[DEBUG] Processing: jboss-kernel-2.0.4.GA.jar
[DEBUG] + WEB-INF/lib/jboss-kernel-2.0.4.GA.jar has been copied.
[DEBUG] Processing: jboss-jpa-deployers-1.0.0-Beta5.jar
[DEBUG] + WEB-INF/lib/jboss-jpa-deployers-1.0.0-Beta5.jar has been copied.
[DEBUG] Processing: jbosssx-2.0.2.SP2.jar
[DEBUG] + WEB-INF/lib/jbosssx-2.0.2.SP2.jar has been copied.
[DEBUG] Processing: jboss-jacc-api-1.1.0.GA_SP1.jar
[DEBUG] + WEB-INF/lib/jboss-jacc-api-1.1.0.GA_SP1.jar has been copied.
[DEBUG] Processing: servlet-api-2.1.1.GA.jar
[DEBUG] + WEB-INF/lib/servlet-api-2.1.1.GA.jar has been copied.
[DEBUG] Processing: jboss-jca-api-1.5.0.GA.jar
[DEBUG] + WEB-INF/lib/jboss-jca-api-1.5.0.GA.jar has been copied.
[DEBUG] Processing: jboss-ejb-api-3.0.0.GA.jar
[DEBUG] + WEB-INF/lib/jboss-ejb-api-3.0.0.GA.jar has been copied.
[DEBUG] Processing: ejb3-persistence-1.0.2.GA.jar
[DEBUG] + WEB-INF/lib/ejb3-persistence-1.0.2.GA.jar has been copied.
[DEBUG] Processing: jboss-classloading-spi-5.0.3.GA.jar
[DEBUG] + WEB-INF/lib/jboss-classloading-spi-5.0.3.GA.jar has been copied.
[DEBUG] Processing: jboss-as-j2se-5.0.1.GA.jar
[DEBUG] + WEB-INF/lib/jboss-as-j2se-5.0.1.GA.jar has been copied.
[DEBUG] Processing: jboss-as-security-5.0.1.GA.jar
[DEBUG] + WEB-INF/lib/jboss-as-security-5.0.1.GA.jar has been copied.
[DEBUG] Processing: jboss-as-deployment-5.0.1.GA.jar
[DEBUG] + WEB-INF/lib/jboss-as-deployment-5.0.1.GA.jar has been copied.
[DEBUG] Processing: jboss-jad-api-1.2.0.GA.jar
[DEBUG] + WEB-INF/lib/jboss-jad-api-1.2.0.GA.jar has been copied.
[DEBUG] Processing: jboss-as-bootstrap-5.0.1.GA.jar
[DEBUG] + WEB-INF/lib/jboss-as-bootstrap-5.0.1.GA.jar has been copied.
Sorry, but this is not the interesting part of the output. M3 prints its dependency tree with all scopes early in the output, normally quite before the log for first goal is printed (at least if one Mojo goal in the lifecycle requires dependency resolution). E.g. for
mvn -X clean compile
you can find the tree directly above the line
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ my-project ---
Ok here it goes these are the entries in the dependency tree related to jboss for this WAR project when ran with -X maven option and they end up in the WEB-INF/lib and I am repeating the same fact again I ran with Maven 2.2.1 and it is working as desired:
[DEBUG] org.jboss.jbossas:jboss-as-tomcat:jar:5.0.1.GA:provided [DEBUG] commons-logging:commons-logging:jar:1.1.0.jboss:compile [DEBUG] apache-xerces:xml-apis:jar:2.9.1:compile [DEBUG] com.sun:jsf-impl:jar:1.2_10:provided [DEBUG] jacorb:jacorb:jar:2.3.0jboss.patch5-brew:provided [DEBUG] javax.security:jaas:jar:1.0.01:runtime [DEBUG] javax.transaction:jta:jar:1.1:compile [DEBUG] org.jboss.logging:jboss-logging-spi:jar:2.0.5.GA:compile [DEBUG] org.jboss.security:jboss-security-spi:jar:2.0.2.SP6:runtime [DEBUG] jboss:jboss-serialization:jar:1.0.3.GA:provided [DEBUG] org.jboss.integration:jboss-deployment-spi:jar:5.0.3.GA:runtime [DEBUG] org.jboss.security:jbosssx-client:jar:2.0.2.SP6:compile [DEBUG] jboss.web:jbossweb:jar:2.1.2.GA:provided [DEBUG] org.jboss.ws.native:jbossws-native-jaxws:jar:3.0.5.GA:runtime [DEBUG] org.jboss.ws.native:jbossws-native-saaj:jar:3.0.5.GA:compile [DEBUG] jgroups:jgroups:jar:2.6.7.GA:provided [DEBUG] log4j:log4j:jar:1.2.14:compile [DEBUG] org.jboss:jboss-common-core:jar:2.2.11.GA:compile [DEBUG] org.jboss.metadata:jboss-metadata:jar:1.0.0.CR16:compile [DEBUG] org.jboss.ejb3:jboss-ejb3-ext-api:jar:1.0.0:compile [DEBUG] org.jboss.javaee:jboss-jms-api:jar:1.1.0.GA:compile [DEBUG] org.jboss.javaee:jboss-transaction-api:jar:1.0.1.GA:compile [DEBUG] jboss.jbossws:jboss-jaxws:jar:3.0.1-native-2.0.4.GA:compile [DEBUG] org.jboss:jboss-mdr:jar:2.0.0.GA:compile [DEBUG] sun-jaxb:jaxb-api:jar:2.1.4:compile [DEBUG] org.jboss:jboss-vfs:jar:2.1.0.GA:compile [DEBUG] org.jboss.ws:jbossws-spi:jar:1.0.7.GA:compile [DEBUG] org.apache.ant:ant:jar:1.7.0:compile [DEBUG] org.apache.ant:ant-launcher:jar:1.7.0:compile [DEBUG] dom4j:dom4j:jar:1.6.1:compile [DEBUG] xml-apis:xml-apis:jar:1.0.b2:compile [DEBUG] gnu-getopt:getopt:jar:1.0.13:compile [DEBUG] org.jboss:jbossxb:jar:2.0.0.GA:compile [DEBUG] org.jboss:jboss-reflect:jar:2.0.0.GA:compile [DEBUG] apache-xerces:xercesImpl:jar:2.9.1:compile [DEBUG] wutka-dtdparser:dtdparser121:jar:1.2.1:compile [DEBUG] org.jboss.aop:jboss-aop:jar:2.0.1.GA:runtime [DEBUG] javassist:javassist:jar:3.9.0.GA:runtime [DEBUG] qdox:qdox:jar:1.6.1:compile [DEBUG] trove:trove:jar:2.1.1:compile [DEBUG] org.jboss.logging:jboss-logging-log4j:jar:2.0.5.GA:compile [DEBUG] org.jboss.javaee:jboss-jaspi-api:jar:1.0.0.GA:compile [DEBUG] org.jboss.jbossas:jboss-as-connector:jar:5.0.1.GA:provided [DEBUG] org.jboss.jbossas:jboss-as-profileservice:jar:5.0.1.GA:provided [DEBUG] org.jboss.jbossas:jboss-as-aspects:jar:5.0.1.GA:provided [DEBUG] org.jboss.aop:jboss-aop-aspects:jar:2.0.1.GA:provided [DEBUG] org.jboss.aop:jboss-aop-asintegration-core:jar:2.0.1.GA:provided [DEBUG] org.jboss.aop:pluggable-instrumentor:jar:2.0.1.GA:provided [DEBUG] org.jboss.aop:jboss-aop-asintegration-jmx:jar:2.0.1.GA:provided [DEBUG] org.jboss.aop:jboss-aop-asintegration-mc:jar:2.0.1.GA:provided [DEBUG] org.jboss.test:jboss-test:jar:1.1.3.GA:compile [DEBUG] org.apache.ant:ant-junit:jar:1.7.0:compile [DEBUG] jboss.profiler.jvmti:jboss-profiler-jvmti:jar:1.0.0.CR5:compile [DEBUG] org.jboss.jbossas:jboss-server-manager:jar:1.0.0.GA:compile [DEBUG] org.jboss.jbossas:jboss-as-server:jar:client:5.0.0.CR2:runtime [DEBUG] org.jboss.jbossas:jboss-as-server:jar:jmx-invoker-adaptor-client:5.0.0.CR2:runtime [DEBUG] org.jboss.integration:jboss-profileservice-spi:jar:5.0.3.GA:compile [DEBUG] org.jboss.microcontainer:jboss-aop-mc-int:jar:2.0.4.GA:runtime [DEBUG] org.jboss.jbossas:jboss-as-system:jar:5.0.1.GA:runtime [DEBUG] org.jboss.integration:jboss-transaction-spi:jar:5.0.3.GA:runtime [DEBUG] org.jboss.integration:jboss-integration:jar:5.0.3.GA:provided [DEBUG] org.jboss.jbossas:jboss-as-main:jar:5.0.1.GA:compile [DEBUG] org.jboss.man:jboss-metatype:jar:2.0.0.GA:compile [DEBUG] org.jboss.man:jboss-managed:jar:2.0.0.GA:compile [DEBUG] org.jboss.jbossas:jboss-as-ejb3:jar:5.0.1.GA:provided [DEBUG] cglib:cglib:jar:2.1.3:runtime [DEBUG] org.hibernate:hibernate-core:jar:3.3.1.GA:runtime [DEBUG] org.hibernate:hibernate-annotations:jar:3.4.0.GA:runtime [DEBUG] org.hibernate:hibernate-commons-annotations:jar:3.1.0.GA:runtime [DEBUG] org.jboss.remoting:jboss-remoting:jar:2.5.0.SP2:runtime [DEBUG] org.hibernate:hibernate-entitymanager:jar:3.4.0.GA:runtime [DEBUG] org.jboss.cluster:jboss-ha-client:jar:1.1.1.GA:provided [DEBUG] org.jboss.ejb3:jboss-ejb3-as-int:jar:1.0.0:provided [DEBUG] org.jboss.ejb3:jboss-ejb3-core:jar:1.0.0:provided [DEBUG] org.jboss.ejb3:jboss-ejb3-deployers:jar:1.0.0:provided [DEBUG] org.jboss.ejb3:jboss-ejb3-mc-int:jar:1.0.0:provided [DEBUG] org.jboss.naming:jnp-client:jar:5.0.1.GA:compile [DEBUG] org.jboss.microcontainer:jboss-kernel:jar:2.0.4.GA:compile [DEBUG] org.jboss.integration:jboss-corba-ots-spi:jar:5.0.3.GA:provided [DEBUG] org.jboss.ejb3:jboss-ejb3-core:jar:client:1.0.0:provided [DEBUG] org.jboss.integration:jboss-jca-spi:jar:5.0.3.GA:provided [DEBUG] org.jboss.cache:jbosscache-core:jar:3.2.5.GA:provided (version managed from 3.0.0.CR4) [DEBUG] org.jboss.aspects:jboss-remoting-aspects:jar:1.0.1.CR4:provided [DEBUG] org.jboss.aspects:jboss-transaction-aspects:jar:1.0.0.Beta1:provided [DEBUG] org.jboss.aspects:jboss-security-aspects:jar:1.0.0.Beta1:provided [DEBUG] javax.security:jacc:jar:1.0:provided [DEBUG] org.jboss.ejb3:jboss-ejb3-async:jar:1.0.0:provided [DEBUG] org.jboss.ejb3:jboss-ejb3-cache:jar:1.0.0:provided [DEBUG] org.jboss.ejb3:jboss-ejb3-common:jar:1.0.0:provided [DEBUG] org.jboss.ejb3:jboss-ejb3-security:jar:1.0.0:provided [DEBUG] org.jboss.aspects:jboss-current-invocation-aspects:jar:1.0.0.CR1:provided [DEBUG] org.jboss.ejb3:jboss-ejb3-ext-api-impl:jar:1.0.0:provided [DEBUG] org.jboss.ejb3:jboss-ejb3-interceptors:jar:1.0.0:provided [DEBUG] org.jboss.ejb3:jboss-ejb3-metadata:jar:1.0.0:provided [DEBUG] org.jboss.ejb3:jboss-ejb3-proxy:jar:1.0.0:provided [DEBUG] org.jboss.ejb3:jboss-ejb3-proxy-clustered:jar:1.0.0:provided [DEBUG] org.jboss.ejb3:jboss-ejb3-transactions:jar:1.0.0:provided [DEBUG] org.jboss.jpa:jboss-jpa-deployers:jar:1.0.0-Beta5:runtime [DEBUG] org.jboss.security:jbosssx:jar:2.0.2.SP2:runtime [DEBUG] sun-jaxws:jaxws-api:jar:2.1.1:provided [DEBUG] sun-jaxws:jsr181-api:jar:2.1.1:provided [DEBUG] org.jboss.javaee:jboss-jacc-api:jar:1.1.0.GA_SP1:runtime [DEBUG] jboss.web:servlet-api:jar:2.1.1.GA:compile [DEBUG] org.jboss.javaee:jboss-jca-api:jar:1.5.0.GA:runtime [DEBUG] org.jboss.javaee:jboss-ejb-api:jar:3.0.0.GA:compile [DEBUG] org.hibernate:ejb3-persistence:jar:1.0.2.GA:compile [DEBUG] org.jboss.cluster:jboss-ha-server-api:jar:1.1.0.GA:provided [DEBUG] org.jboss.cluster:jboss-ha-server-cache-spi:jar:1.1.0.GA:provided [DEBUG] org.jboss.cluster:jboss-ha-server-cache-jbc:jar:1.1.0.GA:provided [DEBUG] org.jboss.jbossas:jboss-as-iiop:jar:5.0.1.GA:provided [DEBUG] apache-avalon:avalon-framework:jar:4.1.5:provided [DEBUG] org.jboss.integration:jboss-classloading-spi:jar:5.0.3.GA:compile [DEBUG] org.jboss.jbossas:jboss-as-j2se:jar:5.0.1.GA:compile [DEBUG] org.jboss.jbossas:jboss-as-security:jar:5.0.1.GA:runtime [DEBUG] org.jboss.jbossas:jboss-as-server:jar:5.0.1.GA:provided [DEBUG] org.jboss.jbossas:jboss-as-deployment:jar:5.0.1.GA:runtime [DEBUG] org.jboss.javaee:jboss-jad-api:jar:1.2.0.GA:compile [DEBUG] org.jboss.jbossas:jboss-as-bootstrap:jar:5.0.1.GA:compile [DEBUG] bcel:bcel:jar:5.1:compile [DEBUG] regexp:regexp:jar:1.2:compile [DEBUG] jpl-util:jpl-util:jar:1.0:runtime [DEBUG] jpl-pattern:jpl-pattern:jar:1.0:runtime [DEBUG] org.jboss.naming:jnpserver:jar:5.0.1.GA:runtime [DEBUG] org.jboss.jbossas:jboss-as-system-jmx:jar:5.0.1.GA:runtime [DEBUG] org.jboss.microcontainer:jboss-dependency:jar:2.0.4.GA:compile [DEBUG] org.jboss.cl:jboss-classloader:jar:2.0.3.GA:compile [DEBUG] org.jboss.deployers:jboss-deployers-core-spi:jar:2.0.5.GA:compile [DEBUG] org.jboss.deployers:jboss-deployers-impl:jar:2.0.5.GA:runtime [DEBUG] org.jboss.cl:jboss-classloading:jar:2.0.3.GA:compile [DEBUG] org.jboss.deployers:jboss-deployers-spi:jar:2.0.5.GA:compile [DEBUG] org.jboss.deployers:jboss-deployers-structure-spi:jar:2.0.5.GA:compile [DEBUG] org.jboss.deployers:jboss-deployers-client-spi:jar:2.0.5.GA:compile [DEBUG] org.jboss.deployers:jboss-deployers-vfs:jar:2.0.5.GA:runtime [DEBUG] org.jboss.deployers:jboss-deployers-vfs-spi:jar:2.0.5.GA:compile [DEBUG] oswego-concurrent:concurrent:jar:1.3.4-jboss-update1:compile [DEBUG] net.jcip:jcip-annotations:jar:1.0:provided [DEBUG] org.slf4j:slf4j-api:jar:1.6.1:provided [DEBUG] org.slf4j:slf4j-log4j12:jar:1.6.1:provided [DEBUG] org.springframework:spring-test:jar:3.0.6.RELEASE:test
In the above post other than the first line
[DEBUG] org.jboss.jbossas:jboss-as-tomcat:jar:5.0.1.GA:provided
all others fall into this dependency there is a spacing issue when I paste it here because all the other dependencies are transitive dependencies for the above jar that I have pasted.
Please edit your comment with the dependencies and use 'noformat' tags around the console output to get the spacings visible (there's a reason for the ? icon below this editor)!
OK, dependency tree is visible now. However, the result is really strange in this case.
Having the same problem, in my case it is the jboss-interceptors-api_1.1_spec artifact. My war project has dependencies on cdi-api v 1.0-SP4 and jboss-as-web v 7.0.2.Final, both as provided. Those two artifacts have dependencies on the interceptors api artifact with versions 1.0.0.Beta1 and 1.0.0.Final so maybe resolving the conflict in the versions is interfering with the provided transitivity logic?
I should add my version is 3.0.4/1.1.0.20120529-1956 (embedded with m2eclipse)
Unfortunately it is no that clear. Actually we're using the jboss-interceptors-api_1.1_spec also, but do not have this effect. So, it is not clear, what triggers the erroneous behavior.
Turns out the m2eclipse dependency hierarchy view was just giving me bad information. It's possible that there is a bug in the maven hierarchy output (which I assume drives the eclipse view) but in my case, I had an errant compile-scoped dependency.
so how come it works fine with Maven 2.2.1 ? It means there is something wrong with the newer versions dependency resolution mechanism
. That erroneous behavior appears with newer versions of Maven it is clear
Same issue with me, also it affects test scope too.
I was very surprised too see servlet-api-2.5 (provided scope) and junit-4.10 (test scope) in my final war in my Spring/GAE/GWT application generated by Spring Roo.
If your google about GWT problems with maven you find a lot of messages like this: http://stackoverflow.com/questions/10671855/unit-testing-app-engine-eclipse-maven.
I think it is the same problem, it is not understandable why test scoped jars (actually it is some mocks used only for unit testing) pulled into final war artifact.
Hey! seems it is maven-war-plugin bug. Just change your final artifact type to jar and wuala! Theres is no strange jars in final artifact!
Yes this is very true. This is a major bug and issue. I am surprised there are no comments and no one has noticed this. We are using the same version of the Maven 3.0.4 and all the Jboss scope as "provided" jars are ending up in the WEB-INF/lib folder. I did spend quite amount of time and then tried the same build with Maven 2.2.1 it is working as desired which is all the transitive dependencies of the dependency that is declared as "provided" scope are not ending up in the WEB-INF/lib folder of the WAR. This needs to addressed as this is totally against the Maven principles.