Title: Problems with Log4j

Hi,

I am currently trying to integrate POI into an existing project that makes use of log4j. Unfortunately I have been unsuccessful [so far] in getting the two to work together - below is a series of cases I have tried to get a working result, including the jars used and the exceptions encountered. The project into which I am trying to integrate POI uses a basic ANT script to clean-compile-jar-sign-test - I encounter the exceptions in the JUnit window as it begins to run the 1st test utilizing the HSSF module.

Any help that anyone can lend me to get this working would be much appreciated.

Case 1. [POI 1.4583 Release, Log4j 1.2 Beta 4, Commons Logging 1.0]
Exception:
java.lang.NoSuchFieldError: INFO
        at org.apache.poi.util.POILogFactory.<init>(POILogFactory.java:120)
        at org.apache.poi.hssf.HSSFLog.<init>(HSSFLog.java:85)
        at org.apache.poi.hssf.HSSFLog.getPOILogger(HSSFLog.java:92)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<clinit>(HSSFWorkbook.java:115)
        ...
Jars Used:
jakarta-poi-1.1-dev.jar from jakarta-poi-1.4583-dev-bin.tar.gz commons-logging-1.0.jar log4j-1.2beta4.jar

Case 2. [POI 1.4583 Release, Log4j 1.1.3, Commons Logging 1.0]
Exception:
java.lang.NoClassDefFoundError: org/apache/log4j/Logger
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<clinit>(HSSFWorkbook.java:115)
        ...
Jars Used:
jakarta-poi-1.1-dev.jar from jakarta-poi-1.4583-dev-bin.tar.gz commons-logging-1.0.jar log4j.jar from jakarta-log4j-1.1.3.tar.gz

Case 3. [POI 1.4583 Release, Log4j Core from CVS, Commons Logging 1.0] Downloaded CVS tree [05/04/2002]
Exception:
java.lang.NoClassDefFoundError: org/apache/log4j/Logger
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<clinit>(HSSFWorkbook.java:115)
        ...
Jars Used:
jakarta-poi-1.1-dev.jar from jakarta-poi-1.4583-dev-bin.tar.gz commons-logging-1.0.jar log4j-core.jar from CVS download [77K Modified 14/03/2002 @ 11:05]

Case 4. [POI built from CVS, Log4j Core from CVS, Commons Logging 1.0] Built POI jar: build.bat -> selected 'compile' target; created jar manually [jar -cvf jakarta-poi-05042002.jar *.*]

Exception:
java.lang.ExceptionInInitializerError: org.apache.commons.logging.LogConfigurationException: java.lang.ClassCastException: org.apache.commons.logging.impl.LogFactoryImpl

        at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:497)
        at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:350)
        at org.apache.poi.util.POILogFactory.<clinit>(POILogFactory.java:76)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<clinit>(HSSFWorkbook.java:113)
        ...
Jars Used:
jakarta-poi-05042002.jar [Freshly built] commons-logging-1.0.jar log4j-core.jar from CVS download [77K Modified 14/03/2002 @ 11:05]

Case 5. [Try to build POI distro using 'dist' target]
build.bat -> Select 'dist' target
Info screen says that script is about to build src and bin distributions Runs 'dist-src' target Runs 'dist-src-tgz' target (Unusual warning "Nothing to do" from gzip, tar isn't gzipped) [Creates jakarta-poi-1.5.0-dev-src.tar in dist directory] Runs 'dist-src-zip' target [Creates jakarta-poi-1.5.0-dev-src.zip in dist directory] Runs 'dist' target and ends abruptly [no warnings] No binary distribution targets were created.

Case 6. [POI built from CVS with Log4j 1.1.3, Commons Logging 1.0] Removed build and dist directories Deleted log4j-core.jar in lib\optional directory Added log4j.jar from jakarta-log4j-1.1.3.tar.gz into lib\optional directory Built POI jar: build.bat -> selected 'compile' target; created jar manually [jar -cvf jakarta-poi-05042002.jar *.*] (Well actually I typed 'tar -cvf ...' and sat there wondering why until my sanity kicked back in again for a bit)

Exception:
java.lang.ExceptionInInitializerError: org.apache.commons.logging.LogConfigurationException: java.lang.ClassCastException: org.apache.commons.logging.impl.LogFactoryImpl

        at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:497)
        at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:350)
        at org.apache.poi.util.POILogFactory.<clinit>(POILogFactory.java:76)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<clinit>(HSSFWorkbook.java:113)
        ...
Jars Used:
jakarta-poi-05042002.jar [Freshly built] commons-logging-1.0.jar log4j.jar from jakarta-log4j-1.1.3.tar.gz

Thanks & Regards,

Gus Power.

Reply via email to