3

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
Mark Stewart
  • 2,046
  • 4
  • 22
  • 32
manurajhada
  • 5,284
  • 3
  • 24
  • 43
  • what is the output of "mvn dependency:tree"? – bowmore Dec 31 '12 at 11:36
  • @bowmore: its.. [INFO] Scanning for projects... [INFO] Reactor build order: [INFO] Service contract database [INFO] SCD-common [INFO] SCD-WEB [INFO] Searching repository for plugin wit Downloading: – manurajhada Dec 31 '12 at 11:42
  • 1
    You should put that output in the question, not in a comment :) – bowmore Dec 31 '12 at 11:43

4 Answers4

3

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.

ben75
  • 29,217
  • 10
  • 88
  • 134
2

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>
JoG
  • 6,612
  • 1
  • 15
  • 9
2

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.

bowmore
  • 10,842
  • 1
  • 35
  • 43
  • Thanks @bowmore, `org.apache.poi:poi:jar:3.8` is also in dependency, As I mentioned whole output is too long to paste here. But I have seen 3.8 is also there. – manurajhada Dec 31 '12 at 12:38
  • 2
    it's just no good trying to analyze partial output. If you could upload it elsewhere (pastebin?) and provide a link, that would definitely help – bowmore Dec 31 '12 at 13:03
0

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.

Community
  • 1
  • 1
Joop Eggen
  • 107,315
  • 7
  • 83
  • 138