Bug 61298 - NoClassDefFoundError: org/apache/commons/collections4/bidimap/TreeBidiMap
Summary: NoClassDefFoundError: org/apache/commons/collections4/bidimap/TreeBidiMap
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: POIFS (show other bugs)
Version: 3.16-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-14 00:37 UTC by Frank van der Hulst
Modified: 2017-07-14 00:43 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frank van der Hulst 2017-07-14 00:37:08 UTC
Code that worked in v3.15 doesn't work with v3.16 and v3.17beta. At runtime, I get an exception for

new PropertySet(dis)

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections4/bidimap/TreeBidiMap
	at org.apache.poi.hpsf.Section.<init>(Section.java:178)
	at org.apache.poi.hpsf.MutableSection.<init>(MutableSection.java:41)
	at org.apache.poi.hpsf.PropertySet.init(PropertySet.java:494)
	at org.apache.poi.hpsf.PropertySet.<init>(PropertySet.java:196)
	at documents.WordDoc.getDocMetadata(WordDoc.java:626)
	at documents.WordDoc.<init>(WordDoc.java:89)
	at documents.Scan.rhapsodyCheckFile(Scan.java:205)
	at documents.Scan.rhapsodyCheckFile(Scan.java:153)
	at documents.Scan.checkFile(Scan.java:625)
	at rhapsody.Overnight.checkFilesForFolder(Overnight.java:158)
	at documents.Scan.main(Scan.java:830)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections4.bidimap.TreeBidiMap
	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
	... 11 more

  public WordDoc(File file) throws IOException {
    try {
      try {
        hdoc = new HWPFDocument(new FileInputStream(file));
        getDocMetadata(file);
// snip
      } catch (IllegalArgumentException ex) {
        if (!ex.getMessage().contains("Office 2007+ XML")) {
          Scan.reportError(0, file.getPath(), null, null, null, null, null, null, ex.getMessage(), null, null);
          throw new IOException();
        }
  }

  private void getDocMetadata(File file) throws IOException {
    POIFSFileSystem poifs = new POIFSFileSystem(new FileInputStream(file));
    DirectoryEntry dir = poifs.getRoot();
    DocumentEntry siEntry = (DocumentEntry) dir.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
    DocumentInputStream dis = new DocumentInputStream(siEntry);
    try {
      SummaryInformation si = new SummaryInformation(new PropertySet(dis));
// snip
    } catch (UnexpectedPropertySetTypeException ex) {
    } catch (NoPropertySetStreamException ex) {
    } catch (MarkUnsupportedException ex) {
    } catch (UnsupportedEncodingException ex) {
    }
  }
Comment 1 Javen O'Neal 2017-07-14 00:43:56 UTC
Note that Apache Commons Collection was added as a dependency recently.

In the changelog for POI 3.16 beta 2:
https://poi.apache.org/changes.html#3.16-beta2

Documented as a dependency for the poi.jar artifact:
https://poi.apache.org/overview.html#components