NoSuchMethodError: org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

NoSuchMethodError: org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit

Dieter
Hello,
I downloaded poi-bin-4.1.0 and added all jar files including the ones in the
lib folder to my project.
The code works for xls files, but with xlsx files the following error
occurs:

Caused by: java.lang.NoSuchMethodError:
org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit(I)Lorg/apache/xmlbeans/XmlOptions;
        at org.apache.poi.ooxml.POIXMLTypeLoader.<clinit>(POIXMLTypeLoader.java:43)
        at org.apache.poi.xssf.model.ThemesTable.<init>(ThemesTable.java:86)
        ... 27 more

Coding sample:

import java.io.*;
import java.math.BigDecimal;
import java.util.*;

import org.apache.poi.ss.usermodel.*; // POI 4.x
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

        public void execute() throws Exception {
                String[][] data = new String[1000][1000];
                FileInputStream fis;
                        try {
                                fis = new FileInputStream(Filename.toString());
                        } catch (FileNotFoundException e) {
                                e.printStackTrace();
                                return;
                        }
                        Workbook wb = null;

                        try {
                          if (Filename.toString().toLowerCase().endsWith(".xls")) {
                            wb = new HSSFWorkbook(new POIFSFileSystem(fis)); // *.xls
                          } else if (Filename.toString().toLowerCase().endsWith(".xlsx")) {
  wb = new XSSFWorkbook(fis); // *.xlsx
                          }
                        } catch (IOException e) {
                                e.printStackTrace();
                                return;
                        }

                        Sheet sheet = wb.getSheetAt(0); // Get Excel Sheet
                        // Iterate through each row.
                        Iterator rows = sheet.rowIterator();
                        while (rows.hasNext()) {
                                Row row = (Row) rows.next();
                                Iterator cells = row.cellIterator();
                                while (cells.hasNext()) {
                                        Cell cell = (Cell) cells.next();
                                        String vCellValue = cell.toString();
                                        data[ row.getRowNum() ][ cell.getColumnIndex() ] = vCellValue;
                                }
                        }
        }




--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: NoSuchMethodError: org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit

Dominik Stadler
Hi,

Sounds like you are using an incorrect version of the XMLBeans library.
Make sure that version 3.1.0 is available and no other version is included
in the classpath.

Dominik.

On Mon, May 13, 2019 at 2:43 PM Dieter <[hidden email]> wrote:

> Hello,
> I downloaded poi-bin-4.1.0 and added all jar files including the ones in
> the
> lib folder to my project.
> The code works for xls files, but with xlsx files the following error
> occurs:
>
> Caused by: java.lang.NoSuchMethodError:
>
> org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit(I)Lorg/apache/xmlbeans/XmlOptions;
>         at
> org.apache.poi.ooxml.POIXMLTypeLoader.<clinit>(POIXMLTypeLoader.java:43)
>         at
> org.apache.poi.xssf.model.ThemesTable.<init>(ThemesTable.java:86)
>         ... 27 more
>
> Coding sample:
>
> import java.io.*;
> import java.math.BigDecimal;
> import java.util.*;
>
> import org.apache.poi.ss.usermodel.*; // POI 4.x
> import org.apache.poi.hssf.usermodel.HSSFWorkbook;
> import org.apache.poi.poifs.filesystem.POIFSFileSystem;
> import org.apache.poi.xssf.usermodel.XSSFWorkbook;
>
>         public void execute() throws Exception {
>                 String[][] data = new String[1000][1000];
>                 FileInputStream fis;
>                         try {
>                                 fis = new
> FileInputStream(Filename.toString());
>                         } catch (FileNotFoundException e) {
>                                 e.printStackTrace();
>                                 return;
>                         }
>                         Workbook wb = null;
>
>                         try {
>                           if
> (Filename.toString().toLowerCase().endsWith(".xls")) {
>                             wb = new HSSFWorkbook(new
> POIFSFileSystem(fis)); // *.xls
>                           } else if
> (Filename.toString().toLowerCase().endsWith(".xlsx")) {
>                                 wb = new XSSFWorkbook(fis); // *.xlsx
>                           }
>                         } catch (IOException e) {
>                                 e.printStackTrace();
>                                 return;
>                         }
>
>                         Sheet sheet = wb.getSheetAt(0); // Get Excel Sheet
>                         // Iterate through each row.
>                         Iterator rows = sheet.rowIterator();
>                         while (rows.hasNext()) {
>                                 Row row = (Row) rows.next();
>                                 Iterator cells = row.cellIterator();
>                                 while (cells.hasNext()) {
>                                         Cell cell = (Cell) cells.next();
>                                         String vCellValue =
> cell.toString();
>                                         data[ row.getRowNum() ][
> cell.getColumnIndex() ] = vCellValue;
>                                 }
>                         }
>         }
>
>
>
>
> --
> Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: NoSuchMethodError: org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit

Dieter
Thanks. I found the old XMLBeans library



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]