manurajhada
manurajhada

Reputation: 5380

Maven Dependancy Refereing old Poi Version

I am using Apache Poi version 3.8 in my POM. But it is still downloading poi-3.2 along with poi-3.8 as (may be) due to some internal dependency. The strange behavior for me is My project using poi-3.2 when even I have mentioned 3.8 version in POM. I have Googled a lot for the same, but found myself unlucky. Here is my POM entry :

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>3.8</version>
    <type>jar</type>
</dependency>

I have checked the poi jar my project using in classpath by the code:

    ClassLoader classloader =
               org.apache.poi.poifs.filesystem.POIFSFileSystem.class.getClassLoader();
            URL res = classloader.getResource(
                         "org/apache/poi/poifs/filesystem/POIFSFileSystem.class");
            String path = res.getPath();
            System.out.println("Core POI came from " + path);

This prints :

Core POI came from file:/D:/Software/Softwares/apache-tomcat-6.0.33/webapps/scd-web/WEB-INF/lib/poi-3.2.jar!/org/apache/poi/poifs/filesystem/POIFSFileSystem.class

There is a poi-3.8.jar in same folder but classpath picking up 3.2.

My question is : What should I do to so that My project uses poi-3.8.jar instead of poi-3.2.jar.

Many Thanks !!

Edited: Output of mvn dependency:tree

 [INFO] Building SCD-common [INFO]    task-segment: [dependency:tree]
 [INFO]
 ------------------------------------------------------------------------ 
 [WARNING] While downloading xmlbeans:xmlbeans:2.3.0   This artifact has been relocated to org.apache.xmlbeans:xmlbeans:2.3.0.
 [INFO] [dependency:tree] [INFO] com.idc:scd-common:jar:4.2.0.5 
 [INFO]  +- org.springframework:spring-webmvc:jar:2.5.6:compile 
 [INFO]  |  +- commons-logging:commons-logging:jar:1.1.1:compile 
 [INFO]  |  +- org.springframework:spring-beans:jar:2.5.6:compile 
 [INFO]  |  +- org.springframework:spring-context-support:jar:2.5.6:compile 
 [INFO]  |     \- org.springframework:spring-web:jar:2.5.6:compile 
 [INFO]  +- com.idc.worldwide.keystones:service-single-signon-dynamo-api:jar:1.0:compile 
 [INFO]  +- com.idc.worldwide.keystones:service-single-signon-dynamo-database-impl:jar:1.0.3:compile 
 [INFO]  |  +- org.apache:commons-dbcp:jar:1.2.2:compile 
 [INFO]  |  +- org.apache:commons-pool:jar:1.4:compile 
 [INFO]  |  \- com.idc.worldwide.webchannel:sage-core:jar:3.2.0.001:compile 
 [INFO]  |     +- com.idc.webchannel.legacy.sage-dependencies:aspose-slides:jar:1. 0:compile 
 [INFO]  |     +- com.servlets:cos:jar:09May2002:compile
 [INFO]  |     +- com.sun:jai_codec:jar:1.1.3:compile 
 [INFO]  |     +- com.sun:jai_core:jar:1.1.3:compile 
 [INFO]  |     +- com.verity:k2:jar:5.00.3177.0:compile 
 [INFO]  |     +- org.apache:poi:jar:3.2:compile 
 [INFO]  |     +- org.apache:poi_contrib:jar:3.2:compile 
 [INFO]  |     +- org.apache:poi_scratchpad:jar:3.2:compile 
 [INFO]  |     \- org.springframework:spring:jar:2.5.6:compile 
 [INFO]  +- org.springframework:spring-core:jar:3.0.5.RELEASE:compile 
 [INFO]  |  \- org.springframework:spring-asm:jar:3.0.5.RELEASE:compile 
 [INFO]  +- org.springframework:spring-aop:jar:3.0.5.RELEASE:compile

Upvotes: 3

Views: 1941

Answers (4)

bowmore
bowmore

Reputation: 11308

Looks like

org.apache:poi:jar:3.2

is a compile dependency of

com.idc.worldwide.keystones:service-single-signon-dynamo-database-impl

(although I think you may have cut something)

and

org.apache.poi:poi:jar:3.8

is not a dependency (it's not in the dependency tree).

Make sure your <dependency> entry is within the <dependencies> tag.

Upvotes: 2

ben75
ben75

Reputation: 28726

There are various mvn command to help solving this issue:

mvn dependency:analyze-dep-mgt

will print details about dependency resolving.

mvn dependency:tree

will print the dependency tree (very helpful to see dependencies of your dependencies)

mvn help:effective-pom

will print the pom resulting from the merge of your pom hierarchy.

If you don't find any references to poi-3.2 with maven, you can take a look at your classpath in your IDE. Do you add any jar by-passing maven ?

Editing your question with the result of those commands can be useful for us to help you.

Upvotes: 3

JoG
JoG

Reputation: 6732

Run

mvn dependency:tree 

to check which library has a transitive dependency to poi 3.2. You can then exclude it in your pom.

<dependency>
  <groupId>sample.group</groupId>
  <artifactId>sample-artifactB</artifactId>
  <version>1</version>
  <exclusions>
    <groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
   </exclusion>
  </exclusions>
</dependency>

Upvotes: 2

Joop Eggen
Joop Eggen

Reputation: 109593

Maybe you are mixing normal dependency with plugin dependency, see here (not too fitting answer).

Use dependency management in the root POM if you have child projects.

Upvotes: 0

Related Questions