Problem Using POI To Set CellStyleProperty With HSSFCellUtil

Posted by Alvin Sim on Stack Overflow See other posts from Stack Overflow or by Alvin Sim
Published on 2010-06-08T02:52:04Z Indexed on 2010/06/08 5:42 UTC
Read the original article Hit count: 983

Filed under:
|
|
|

I have a Java class which uses Apache POI to generate reports in Excel.

When I run the Java class from my IDE or command prompt, I only see warning messages from LOG4J as below:

log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.converters.BooleanConverter).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

Despite the warning messages, the report was generated successfully.

But when I run it from my web app, which uses JSP and submits the form to a Servlet which calls the Java class, the Java class seems to have problems setting the style properties to the cell. Below are the Java code and also the stack trace.

I'm testing this on a Standalone OC4J and the IDE which I'm using is Oracle's JDeveloper. And the Java JDK is 1.4.2.

I've been looking high and low the whole day yesterday but can't seem to find out why.

Code:

region = new Region(1, (short) 1, 5, (short)2);      
sheet.addMergedRegion(region);
HSSFRegionUtil.setBorderBottom( (short) 1, region, sheet, workBook );

Stack trace:

10/06/07 16:03:17 SvltRptProcessor ACTION=print_to_file RPT_CLASSNAME=com.reports.BP.DailySalesBudgetExcelRpt DES_TYPE=file DES_FORMAT=xls
10/06/07 16:03:17 rptFilename=/oracle/reports//20100607_160317_BP_DailySalesBudgetByPmgrp_OPR.xls
10/06/07 16:03:17 ReportRunner printToFile execute -> com.reports.BP.DailySalesBudgetExcelRpt
10/06/07 16:03:17 enter daily sales budget excel rpt -----> print()
10/06/07 16:03:18 Tutalii: C:\oc4j10gmy\j2ee\home\applib\poi-2.5.1.jar archive
10/06/07 16:03:19 org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor
10/06/07 16:03:19       at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:509)
10/06/07 16:03:19       at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:285)
10/06/07 16:03:19       at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:255)
10/06/07 16:03:19       at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:381)
10/06/07 16:03:19       at org.apache.commons.beanutils.ConvertUtilsBean.<init>(ConvertUtilsBean.java:157)
10/06/07 16:03:19       at org.apache.commons.beanutils.BeanUtilsBean.<init>(BeanUtilsBean.java:117)
10/06/07 16:03:19       at org.apache.commons.beanutils.BeanUtilsBean$1.initialValue(BeanUtilsBean.java:68)
10/06/07 16:03:19       at org.apache.commons.beanutils.ContextClassLoaderLocal.get(ContextClassLoaderLocal.java:153)
10/06/07 16:03:19       at org.apache.commons.beanutils.BeanUtilsBean.getInstance(BeanUtilsBean.java:80)
10/06/07 16:03:19       at org.apache.commons.beanutils.PropertyUtilsBean.getInstance(PropertyUtilsBean.java:114)
10/06/07 16:03:19       at org.apache.commons.beanutils.PropertyUtils.describe(PropertyUtils.java:209)
10/06/07 16:03:19       at org.apache.poi.hssf.usermodel.contrib.HSSFCellUtil.setCellStyleProperty(HSSFCellUtil.java:174)
10/06/07 16:03:19       at org.apache.poi.hssf.usermodel.contrib.HSSFRegionUtil.
setBorderBottom(HSSFRegionUtil.java:153)
10/06/07 16:03:19       at com.reports.BP.DailySalesBudgetExcelRpt.setRegion(DailySalesBudgetExcelRpt.java:773)
10/06/07 16:03:19       at com.reports.BP.DailySalesBudgetExcelRpt.createHdr(DailySalesBudgetExcelRpt.java:308)
10/06/07 16:03:19       at com.reports.BP.DailySalesBudgetExcelRpt.start(DailySalesBudgetExcelRpt.java:272)
10/06/07 16:03:19       at com.reports.BP.DailySalesBudgetExcelRpt.print(DailySalesBudgetExcelRpt.java:222)
10/06/07 16:03:19       at com.servlet.RPT.ReportRunner.printToFile(ReportRunner.java:601)
10/06/07 16:03:19       at com.servlet.RPT.ReportRunner.doPrint(ReportRunner.java:302)
10/06/07 16:03:19       at com.servlet.RPT.ReportRunner.run(ReportRunner.java:270)
10/06/07 16:03:19       at java.lang.Thread.run(Thread.java:619)
10/06/07 16:03:19 Caused by: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor
10/06/07 16:03:19       at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:420)
10/06/07 16:03:19       at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:502)
10/06/07 16:03:19       ... 20 more
10/06/07 16:03:19 Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Category
10/06/07 16:03:19       at java.lang.Class.getDeclaredConstructors0(Native Method)
10/06/07 16:03:19       at java.lang.Class.privateGetDeclaredConstructors(Class.
java:2389)
10/06/07 16:03:19       at java.lang.Class.getConstructor0(Class.java:2699)
10/06/07 16:03:19       at java.lang.Class.getConstructor(Class.java:1657)
10/06/07 16:03:19       at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:417)
10/06/07 16:03:19       ... 21 more
10/06/07 16:03:19 Caused by: java.lang.ClassNotFoundException: org.apache.log4j.
Category
10/06/07 16:03:19       at java.net.URLClassLoader$1.run(URLClassLoader.java:202
)
10/06/07 16:03:19       at java.security.AccessController.doPrivileged(Native Method)
10/06/07 16:03:19       at java.net.URLClassLoader.findClass(URLClassLoader.java
:190)
10/06/07 16:03:19       at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

10/06/07 16:03:19       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
10/06/07 16:03:19       at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

10/06/07 16:03:19       ... 26 more
org.apache.commons.lang.exception.NestableException: Couldn't setCellStyleProperty.
        at org.apache.poi.hssf.usermodel.contrib.HSSFCellUtil.setCellStyleProperty(HSSFCellUtil.java:209)
        at org.apache.poi.hssf.usermodel.contrib.HSSFRegionUtil.setBorderBottom(HSSFRegionUtil.java:153)
        at com.reports.BP.DailySalesBudgetExcelRpt.setRegion(DailySalesBudgetExcelRpt.java:773)
        at com.reports.BP.DailySalesBudgetExcelRpt.createHdr(DailySalesBudgetExcelRpt.java:308)
        at com.reports.BP.DailySalesBudgetExcelRpt.start(DailySalesBudgetExcelRpt.java:272)
        at com.reports.BP.DailySalesBudgetExcelRpt.print(DailySalesBudgetExcelRpt.java:222)
        at com.servlet.RPT.ReportRunner.printToFile(ReportRunner.java:601)
        at com.servlet.RPT.ReportRunner.doPrint(ReportRunner.java:302)
        at com.servlet.RPT.ReportRunner.run(ReportRunner.java:270)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor
        at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:509)
        at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:285)
        at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:255)
        at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:381)
        at org.apache.commons.beanutils.ConvertUtilsBean.<init>(ConvertUtilsBean.java:157)
        at org.apache.commons.beanutils.BeanUtilsBean.<init>(BeanUtilsBean.java:117)
        at org.apache.commons.beanutils.BeanUtilsBean$1.initialValue(BeanUtilsBean.java:68)
        at org.apache.commons.beanutils.ContextClassLoaderLocal.get(ContextClassLoaderLocal.java:153)
        at org.apache.commons.beanutils.BeanUtilsBean.getInstance(BeanUtilsBean.java:80)
        at org.apache.commons.beanutils.PropertyUtilsBean.getInstance(PropertyUtilsBean.java:114)
        at org.apache.commons.beanutils.PropertyUtils.describe(PropertyUtils.java:209)
        at org.apache.poi.hssf.usermodel.contrib.HSSFCellUtil.setCellStyleProperty(HSSFCellUtil.java:174)
        ... 9 more
Caused by: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor
        at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:420)
        at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactory
Impl.java:502)
        ... 20 more
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Category
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
        at java.lang.Class.getConstructor0(Class.java:2699)
        at java.lang.Class.getConstructor(Class.java:1657)
        at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:417)
        ... 21 more
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Category
        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)
        ... 26 more

© Stack Overflow or respective owner

Related posts about java

Related posts about logging