Search code examples
javamavencompilationapache-poidbunit

POI 3.8 incompatible with dbunit 2.4.9


We are using POI 3.8 in in our application. Our project is using dbunit to load data sets from .xls files, and apparently dbunit is incompatible with POI 3.8. I get the following exception,

java.lang.NoSuchMethodError: org.apache.poi.hssf.usermodel.HSSFDateUtil.isCellDateFormatted(Lorg/apache/poi/hssf/usermodel/HSSFCell;)Z 

It seems dbunit requires POI 3.2. However I cannot downgrade my POI version. Is there any way to fix this problem. In a post I read about downloading dbunit sources and recompile it against poi 3.8. How can this recompiling be done?


Solution

  • There is some discussion about this at the dbunit-bugtracker at http://sourceforge.net/p/dbunit/bugs/332/, unfortunately no update there yet, so it seems dbunit itself does not support this yet.

    I was able to recompile dbunit against a newer Apache POI version with the following steps:

    1. Check out dbunit code from http://dbunit.svn.sourceforge.net/svnroot/dbunit/tags/dbunit-2.4.9 via svn co http://dbunit.svn.sourceforge.net/svnroot/dbunit/tags/dbunit-2.4.9
    2. Adjust pom.xml to set the poi-dependency to just 3.9, the -FINAL was dropped in newer versions
    3. run mvn package
    4. If it fails during compiling because of oracle-jar missing, follow the steps at https://stackoverflow.com/a/18042525/411846
    5. If tests fail during building, you can try to skip them with mvn -DskipTests=true package

    The resulting binary is located under target/dbunit-2.4.9.jar