У меня есть класс Java, который использует Apache POI для создания отчетов в Excel.
Когда я запускаю класс Java из своей IDE или командной строки, я вижу только предупреждающие сообщения из LOG4J, как показано ниже:
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.
Несмотря на предупреждения, отчет был сгенерирован успешно.
Но когда я запускаю его из своего веб-приложения, которое использует JSP и передает форму сервлету, который вызывает класс Java,В Java-классе, похоже, возникают проблемы при настройке свойств стиля для ячейки.Ниже приведен код Java, а также трассировка стека.
Я тестирую это на автономном OC4J, и IDE, которую я использую, является Oracle JDeveloper.А Java JDK - это 1.4.2.
Я вчера весь день искал высоко и низко, но не могу понять, почему.
Код:
region = new Region(1, (short) 1, 5, (short)2);
sheet.addMergedRegion(region);
HSSFRegionUtil.setBorderBottom( (short) 1, region, sheet, workBook );
Трассировка стека:
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