Зависимость Apache POI в проекте Maven: java.lang.NoClassDefFoundError: не удалось инициализировать класс org.apache.poiJAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Зависимость Apache POI в проекте Maven: java.lang.NoClassDefFoundError: не удалось инициализировать класс org.apache.poi

Сообщение Anonymous »

Я хочу экспортировать файл xlsx в проект Java, поэтому добавил библиотеки Apache POI. Однако это не работает. Я удалил зависимость xerces, и она работает, но при попытке экспорта в формат PDF возникает ошибка в существующих функциях. Я делюсь с вами методами, которые я использую с библиотеками Apache POI, а также pom.xml, деревом зависимостей и описаниями ошибок.
Надеюсь, кто-то из вас сможет помогите мне.
Заранее спасибо.
метод Export() :
public ByteArrayOutputStream export() {
CMIS2Logger.trace(CMIS2Logger.LEVEL_LOGGER_INFO, "Début de l'exportation du rapport");
ByteArrayOutputStream outputByteArray = new ByteArrayOutputStream();
XSSFWorkbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet("First Sheet");

try {
Map columnsReportMap = new HashMap();
Map cellStyles = new HashMap();

// Créer les styles de cellules en dehors de la boucle principale
createCellStyles(workbook, cellStyles);
CMIS2Logger.trace(CMIS2Logger.LEVEL_LOGGER_INFO, "Styles de cellules créés");

// Parcourir les rapports
Iterator itReportIDS = getCmis2JRDataSource().getMapReportIDColumns().keySet().iterator();
while (itReportIDS.hasNext()) {
String currentReportId = itReportIDS.next();
CMIS2Logger.trace(CMIS2Logger.LEVEL_LOGGER_INFO, "Traitement du rapport ID: " + currentReportId);
LinkedHashMap columnsReport = (LinkedHashMap) getCmis2JRDataSource().getMapReportIDColumns().get(currentReportId);
columnsReportMap.put(currentReportId, columnsReport);

// Créer les en-têtes de colonne
createColumnHeaders(sheet, columnsReport, cellStyles);
CMIS2Logger.trace(CMIS2Logger.LEVEL_LOGGER_INFO, "En-têtes de colonne créés pour le rapport ID: " + currentReportId);

// Parcourir les enregistrements
Iterator itEnregistrement = getIteratorForReport(currentReportId);
int idRow = 1;
while (itEnregistrement.hasNext()) {
Element current = (Element) itEnregistrement.next();
List childsOfCurrent = current.getChildren();

Row row = sheet.createRow(idRow++);
int idCol = 0;
for (Element node : childsOfCurrent) {
Element columnHeader = columnsReport.get(node.getName());
if (columnHeader != null) {
Cell cell = row.createCell(idCol++);
setCellValue(cell, columnHeader, node.getAttributeValue("value"), cellStyles);
}
}
}
}

// Écrire le classeur Excel dans le ByteArrayOutputStream
workbook.write(outputByteArray);
CMIS2Logger.trace(CMIS2Logger.LEVEL_LOGGER_INFO, "Rapport exporté avec succès");
} catch (IOException e) {
CMIS2Logger.traceException(CMIS2Logger.LEVEL_LOGGER_ERROR,"Erreur lors de l'écriture du fichier Excel", e);
} catch (Exception e) {
CMIS2Logger.traceException(CMIS2Logger.LEVEL_LOGGER_ERROR, "Erreur lors de l'export du fichier Excel", e);
} finally {
try {
workbook.close();
CMIS2Logger.trace(CMIS2Logger.LEVEL_LOGGER_INFO, "Classeur Excel fermé avec succès");
} catch (IOException e) {
CMIS2Logger.traceException( CMIS2Logger.LEVEL_LOGGER_ERROR, "Erreur lors de la fermeture du fichier Excel", e ) ; < b r / > } < b r / > } < b r / > < b r / > r e t u r n o u t p u t B y t e A r r a y ; < b r / > } < b r / > < / к о д > < b r / > p o m . x m l : < / p > < b r / > < c o d e > & l t ; d e p e n d e n c i e s & g t ; < b r / > & l t ; d e p e n d e n c y & g t ; < b r / > & l t ; g r o u p I d & g t ; o r g . a p a c h e . p o i & l t ; / g r o u p I d & g t ; < b r / > & l t ; a r t i f a c t I d & g t ; p o i & l t ; / a r t i f a c t I d & g t ; < b r / > & l t ; v e r s i o n & g t ; 5 . 2 . 5 & l t ; / v e r s i o n & g t ; < b r / > & l t ; / d e p e n d e n c y & g t ; < b r / > & l t ; d e p e n d e n c y & g t ; < b r / > & l t ; g r o u p I d & g t ; o r g . a p a c h e . p o i & l t ; / g r o u p I d & g t ; < b r / > & l t ; a r t i f a c t I d & g t ; p o i - o o x m l & l t ; / a r t i f a c t I d & g t ; < b r / > & l t ; v e r s i o n & g t ; 5 . 2 . 5 & l t ; / v e r s i o n & g t ; < b r / > & l t ; e x c l u s i o n s & g t ; < b r / > & l t ; e x c l u s i o n & g t ; < b r / > & l t ; g r o u p I d & g t ; c o m m o n s - c o l l e c t i o n s & l t ; / g r o u p I d & g t ; < b r / > & l t ; a r t i f a c t I d & g t ; c o m m o n s - c o l l e c t i o n s & l t ; / a r t i f a c t I d & g t ; < b r / > & l t ; / e x c l u s i o n & g t ; < b r / > & l t ; e x c l u s i o n & g t ; < b r / > & l t ; g r o u p I d & g t ; x e r c e s & l t ; / g r o u p I d & g t ; < b r / > & l t ; a r t i f a c t I d & g t ; x e r c e s I m p l & l t ; / a r t i f a c t I d & g t ; < b r / > & l t ; / e x c l u s i o n & g t ; < b r / > & l t ; / e x c l u s i o n s & g t ; < b r / > & l t ; / d e p e n d e n c y & g t ; < b r / > & l t ; d e p e n d e n c y & g t ; < b r / > & l t ; g r o u p I d & g t ; i t e x t & l t ; / g r o u p I d & g t ; < b r / > & l t ; a r t i f a c t I d & g t ; i t e x t & l t ; / a r t i f a c t I d & g t ; < b r / > & l t ; v e r s i o n & g t ; 4 . 2 . 1 & l t ; / v e r s i o n & g t ; < b r / > & l t ; / d e p e n d e n c y & g t ; < b r / > & l t ; d e p e n d e n c y & g t ; < b r / > & l t ; g r o u p I d & g t ; o r g . j d o m & l t ; / g r o u p I d & g t ; < b r / > & l t ; a r t i f a c t I d & g t ; j d o m & l t ; / a r t i f a c t I d & g t ; < b r / > & l t ; v e r s i o n & g t ; 1 . 1 & l t ; / v e r s i o n & g t ; < b r / > & l t ; / d e p e n d e n c y & g t ; < b r / > & l t ; d e p e n d e n c y & g t ; < b r / > & l t ; g r o u p I d & g t ; j a s p e r r e p o r t s & l t ; / g r o u p I d & g t ; < b r / > & l t ; a r t i f a c t I d & g t ; j a s p e r r e p o r t s & l t ; / a r t i f a c t I d & g t ; < b r / > & l t ; v e r s i o n & g t ; 3 . 5 . 3 & l t ; / v e r s i o n & g t ; < b r / > & l t ; / d e p e n d e n c y & g t ; < b r / > & l t ; d e p e n d e n c y & g t ; < b r / > & l t ; g r o u p I d & g t ; f w k & l t ; / g r o u p I d & g t ; < b r / > & l t ; a r t i f a c t I d & g t ; f w k & l t ; / a r t i f a c t I d & g t ; < b r / > & l t ; v e r s i o n & g t ; 2 . 1 . 2 b 2 & l t ; / v e r s i o n & g t ; < b r / > & l t ; / d e p e n d e n c y & g t ; < b r / > & l t ; d e p e n d e n c y & g t ; < b r / > & l t ; g r o u p I d & g t ; f w k & l t ; / g r o u p I d & g t ; < b r / > & l t ; a r t i f a c t I d & g t ; f w k - j n d i & l t ; / a r t i f a c t I d & g t ; < b r / > & l t ; v e r s i o n & g t ; 1 . 1 . 2 b 1 & l t ; / v e r s i o n & g t ; < b r / > & l t ; / d e p e n d e n c y & g t ; < b r / > & l t ; d e p e n d e n c y & g t ; < b r / > & l t ; g r o u p I d & g t ; n e t . a t o s . m m . f w k & l t ; / g r o u p I d & g t ; < b r / > & l t ; a r t i f a c t I d & g t ; s y s m m & l t ; / a r t i f a c t I d & g t ; < b r / > & l t ; v e r s i o n & g t ; 1 . 2 . 2 & l t ; / v e r s i o n & g t ; < b r / > & l t ; / d e p e n d e n c y & g t ; < b r / > & l t ; d e p e n d e n c y & g t ; < b r / > & l t ; g r o u p I d & g t ; j a v a x . x m l & l t ; / g r o u p I d & g t ; < b r / > & l t ; a r t i f a c t I d & g t ; j a x p - a p i & l t ; / a r t i f a c t I d & g t ; < b r / > & l t ; v e r s i o n & g t ; 1 . 4 . 2 & l t ; / v e r s i o n & g t ; < b r / > & l t ; / d e p e n d e n c y & g t ; < b r / > & l t ; d e p e n d e n c y & g t ; < b r / > & l t ; g r o u p I d & g t ; a t o s & l t ; / g r o u p I d & g t ; < b r / > & l t ; a r t i f a c t I d & g t ; j m x r i & l t ; / a r t i f a c t I d & g t ; < b r / > & l t ; v e r s i o n & g t ; 1 . 2 & l t ; / v e r s i o n & g t ; < b r / > & l t ; / d e p e n d e n c y & g t ; < b r / > & l t ; d e p e n d e n c y & g t ; < b r / > & l t ; g r o u p I d & g t ; a t o s & l t ; / g r o u p I d & g t ; < b r / > & l t ; a r t i f a c t I d & g t ; j m x t o o l s & l t ; / a r t i f a c t I d & g t ; < b r / > & l t ; v e r s i o n & g t ; 1 . 2 & l t ; / v e r s i o n & g t ; < b r / > & l t ; / d e p e n d e n c y & g t ; < b r / > & l t ; d e p e n d e n c y & g t ; < b r / > & l t ; g r o u p I d & g t ; f w k & l t ; / g r o u p I d & g t ; < b r / > & l t ; a r t i f a c t I d & g t ; f w k - a d m i n & l t ; / a r t i f a c t I d & g t ; < b r / > & l t ; v e r s i o n & g t ; 2 . 0 . 0 b 2 & l t ; / v e r s i o n & g t ; < b r / > & l t ; / d e p e n d e n c y & g t ; < b r / > & l t ; d e p e n d e n c y & g t ; < b r / > & l t ; g r o u p I d & g t ; f w k & l t ; / g r o u p I d & g t ; < b r / > & l t ; a r t i f a c t I d & g t ; f w k - o p m & l t ; / a r t i f a c t I d & g t ; < b r / > & l t ; v e r s i o n & g t ; 3 - 2 - 0 b 1 & l t ; / v e r s i o n & g t ; < b r / > & l t ; / d e p e n d e n c y & g t ; < b r / > & l t ; d e p e n d e n c y & g t ; < b r / > & l t ; g r o u p I d & g t ; c o m . a t o s o r i g i n . a w l . f w k _ h o m e . l i b & l t ; / g r o u p I d & g t ; < b r / > & l t ; a r t i f a c t I d & g t ; f w 3 & l t ; / a r t i f a c t I d & g t ; < b r / > & l t ; v e r s i o n & g t ; 1 - 4 & l t ; / v e r s i o n & g t ; < b r / > & l t ; / d e p e n d e n c y & g t ; < b r / > & l t ; d e p e n d e n c y & g t ; < b r / > & l t ; g r o u p I d & g t ; n e t . a t o s . m m . f w k & l t ; / g r o u p I d & g t ; < b r / > & l t ; a r t i f a c t I d & g t ; f w 3 - t o o l s & l t ; / a r t i f a c t I d & g t ; < b r / > & l t ; v e r s i o n & g t ; 1 - 0 - 0 b 2 & l t ; / v e r s i o n & g t ; < b r / > & l t ; / d e p e n d e n c y & g t ; < b r / > & l t ; d e p e n d e n c y & g t ; < b r / > & l t ; g r o u p I d & g t ; c o m . a t o s o r i g i n . a w l . j a r _ h o m e . r e g e x p & l t ; / g r o u p I d & g t ; < b r / > & l t ; a r t i f a c t I d & g t ; j a k a r t a - o r o & l t ; / a r t i f a c t I d & g t ; < b r / > & l t ; v e r s i o n & g t ; 2 . 0 . 5 & l t ; / v e r s i o n & g t ; < b r / > & l t ; / d e p e n d e n c y & g t ; < b r / > & l t ; d e p e n d e n c y & g t ; < b r / > & l t ; g r o u p I d & g t ; j a v a x . s e r v l e t & l t ; / g r o u p I d & g t ; < b r / > & l t ; a r t i f a c t I d & g t ; j s t l & l t ; / a r t i f a c t I d & g t ; < b r / > & l t ; v e r s i o n & g t ; 1 . 1 . 2 & l t ; / v e r s i o n & g t ; < b r / > & l t ; / d e p e n d e n c y & g t ; < b r / > & l t ; d e p e n d e n c y & g t ; < b r / > & l t ; g r o u p I d & g t ; t a g l i b s & l t ; / g r o u p I d & g t ; < b r / > & l t ; a r t i f a c t I d & g t ; s t a n d a r d & l t ; / a r t i f a c t I d & g t ; < b r / > 1.1.2


com.microsoft.sqlserver
sqljdbc4
4.2


xpp3
xpp3
1.1.4c


net.awl.reporting
json-rpc
1.0
awl


commons-collections
commons-collections
3.2.1


org.apache.commons
commons-beanutils
1.8.0


commons-logging
commons-logging
1.2


commons-digester
commons-digester
1.8


jxl
jxl
2.6.9


org.jaxen
com.springsource.org.jaxen
1.1.3_compile


xmlParserAPIs
xmlParserAPIs
5.0.0


commons-httpclient
commons-httpclient
3.1


commons-codec
commons-codec
1.4


commons-lang
commons-lang
2.1


xerces
xerces
1.4.4


xerces
xercesImpl
2.7.1


org.apache.logging.log4j
log4j-1.2-api
2.17.1


org.apache.logging.log4j
log4j-api
2.17.1


org.apache.logging.log4j
log4j-core
2.17.1


com.octo.captcha
jcaptcha
1.0


xalan
xalan
2.7.2


javax.mail
mail
1.4.7



дерево зависимостей:[INFO] +- org.apache.poi:poi:jar:5.2.5:compile
[INFO] | +- org.apache.commons:commons-collections4:jar:4.4:compile
[INFO] | +- org.apache.commons:commons-math3:jar:3.6.1:compile
[INFO] | +- commons-io:commons-io:jar:2.15.0:compile
[INFO] | \- com.zaxxer:SparseBitSet:jar:1.3:compile
[INFO] +- org.apache.poi:poi-ooxml:jar:5.2.5:compile
[INFO] | +- org.apache.poi:poi-ooxml-lite:jar:5.2.5:compile
[INFO] | +- org.apache.xmlbeans:xmlbeans:jar:5.2.0:compile
[INFO] | +- org.apache.commons:commons-compress:jar:1.25.0:compile
[INFO] | \- com.github.virtuald:curvesapi:jar:1.08:compile
[INFO] +- itext:itext:jar:4.2.1:compile
[INFO] +- org.jdom:jdom:jar:1.1:compile
[INFO] +- jasperreports:jasperreports:jar:3.5.3:compile
[INFO] | +- commons-beanutils:commons-beanutils:jar:1.8.0:compile
[INFO] | +- com.lowagie:itext:jar:2.1.0:compile
[INFO] | | +- bouncycastle:bcmail-jdk14:jar:136:compile
[INFO] | | \- bouncycastle:bcprov-jdk14:jar:136:compile
[INFO] | +- jfree:jcommon:jar:1.0.15:compile
[INFO] | +- jfree:jfreechart:jar:1.0.12:compile
[INFO] | +- xml-apis:xml-apis:jar:1.3.02:compile
[INFO] | \- eclipse:jdtcore:jar:3.1.0:compile
[INFO] +- fwk:fwk:jar:2.1.2b2:compile
[INFO] +- fwk:fwk-jndi:jar:1.1.2b1:compile
[INFO] +- net.atos.mm.fwk:sysmm:jar:1.2.2:compile
[INFO] +- javax.xml:jaxp-api:jar:1.4.2:compile
[INFO] +- atos:jmxri:jar:1.2:compile
[INFO] +- atos:jmxtools:jar:1.2:compile
[INFO] +- fwk:fwk-admin:jar:2.0.0b2:compile
[INFO] +- fwk:fwk-opm:jar:3-2-0b1:compile
[INFO] +- com.atosorigin.awl.fwk_home.lib:fw3:jar:1-4:compile
[INFO] +- net.atos.mm.fwk:fw3-tools:jar:1-0-0b2:compile
[INFO] +- com.atosorigin.awl.jar_home.regexp:jakarta-oro:jar:2.0.5:compile
[INFO] +- javax.servlet:jstl:jar:1.1.2:compile
[INFO] +- taglibs:standard:jar:1.1.2:compile
[INFO] +- com.microsoft.sqlserver:sqljdbc4:jar:4.2:compile
[INFO] +- xpp3:xpp3:jar:1.1.4c:compile
[INFO] +- net.awl.reporting:json-rpc:jar:awl:1.0:compile
[INFO] +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] +- org.apache.commons:commons-beanutils:jar:1.8.0:compile
[INFO] +- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- commons-digester:commons-digester:jar:1.8:compile
[INFO] +- jxl:jxl:jar:2.6.9:compile
[INFO] +- org.jaxen:com.springsource.org.jaxen:jar:1.1.3_compile:compile
[INFO] +- xmlParserAPIs:xmlParserAPIs:jar:5.0.0:compile
[INFO] +- commons-httpclient:commons-httpclient:jar:3.1:compile
[INFO] +- commons-codec:commons-codec:jar:1.4:compile
[INFO] +- commons-lang:commons-lang:jar:2.1:compile
[INFO] +- xerces:xerces:jar:1.4.4:compile
[INFO] +- xerces:xercesImpl:jar:2.7.1:compile
[INFO] +- org.apache.logging.log4j:log4j-1.2-api:jar:2.17.1:compile
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.17.1:compile
[INFO] +- org.apache.logging.log4j:log4j-core:jar:2.17.1:compile
[INFO] +- com.octo.captcha:jcaptcha:jar:1.0:compile
[INFO] | +- com.octo.captcha:jcaptcha-api:jar:1.0:compile
[INFO] | +- com.jhlabs:imaging:jar:01012005:compile
[INFO] | \- javax.servlet:servlet-api:jar:2.3:compile
[INFO] +- xalan:xalan:jar:2.7.2:compile
[INFO] | \- xalan:serializer:jar:2.7.2:compile
[INFO] \- javax.mail:mail:jar:1.4.7:compile
[INFO] \- javax.activation:activation:jar:1.1:compile

Сообщение об ошибке:
java.lang.NoClassDefFoundError: Could not initialize class org.apache.poi.ooxml.util.DocumentHelper
at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.save(ContentTypeManager.java:429)
at org.apache.poi.openxml4j.opc.ZipPackage.saveImpl(ZipPackage.java:608)
at org.apache.poi.openxml4j.opc.OPCPackage.save(OPCPackage.java:1532)
at org.apache.poi.openxml4j.opc.OPCPackage.close(OPCPackage.java:506)
at org.apache.poi.ooxml.POIXMLDocument.close(POIXMLDocument.java:189)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.close(XSSFWorkbook.java:640)
at cmis2.generation.renderer.JRRendererXLSX.export(JRRendererXLSX.java:95)
at cmis2.application.filtres.FileFilter.downloadForReports(FileFilter.java:387)
at cmis2.application.filtres.FileFilter.doFilter(FileFilter.java:228)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:179)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:154)
at cmis2.application.filtres.FiltreRIGHTS.doFilter(FiltreRIGHTS.java:154)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:179)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:154)
at cmis2.application.filtres.FiltreLOGUE.doFilter(FiltreLOGUE.java:105)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:179)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:154)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:168)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:481)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:130)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:670)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:346)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:390)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:928)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1786)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
at java.lang.Thread.run(Thread.java:748)



Подробнее здесь: https://stackoverflow.com/questions/787 ... or-could-n
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «JAVA»