You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2019/03/30 17:46:43 UTC

[Bug 63303] New: java.io.IOException: java.lang.NoSuchMethodException: org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(java.io.File)

https://bz.apache.org/bugzilla/show_bug.cgi?id=63303

            Bug ID: 63303
           Summary: java.io.IOException: java.lang.NoSuchMethodException:
                    org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.crea
                    teWorkbook(java.io.File)
           Product: POI
           Version: 4.0.x-dev
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: zengxh@gmail.com
  Target Milestone: ---

(WorkbookFactory/create java.io.File) will cause this

java.io.IOException: java.lang.NoSuchMethodException:
org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(java.io.File)
                     WorkbookFactory.java:354
org.apache.poi.ss.usermodel.WorkbookFactory.createWorkbook
                     WorkbookFactory.java:314
org.apache.poi.ss.usermodel.WorkbookFactory.createXSSFWorkbook
                     WorkbookFactory.java:173
org.apache.poi.ss.usermodel.WorkbookFactory.create

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63303] java.io.IOException: java.lang.NoSuchMethodException: org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(java.io.File)

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63303

--- Comment #8 from Dominik Stadler <do...@gmx.at> ---
Change 1832358 in Bug #62355 seems related, we changed interface from
OPCPackage to Object for one method in order to support Java 11 properly,
however this seems to break cases where you now try to provide a "File" as
"Object" somehow in the parameters and thus the wrong method is selected for
execution.

We have tests that create(File) still works as expected, so something in your
code seems to trigger this and so it most likely will need some modification
there to be fixed.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63303] java.io.IOException: java.lang.NoSuchMethodException: org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(java.io.File)

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63303

--- Comment #6 from zengxh@gmail.com ---
According to the source
https://svn.apache.org/repos/asf/poi/trunk/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java

In method createWorkbook(String, Object[]) it will try to look for
org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(java.io.File,
Boolean). When the method is not found it's not found exception is thrown
https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getMethod-java.lang.String-java.lang.Class...-


    private static Workbook createXSSFWorkbook(Object... args) throws
IOException, EncryptedDocumentException {
        return
createWorkbook("org.apache.poi.xssf.usermodel.XSSFWorkbookFactory", args);
    }

    /**
     * Does the actual call to HSSF or XSSF to do the creation.
     * Uses reflection, so that this class can be in the Core non-OOXML
     *  POI jar without errors / broken references to the OOXML / XSSF code.
     */
    private static Workbook createWorkbook(String factoryClass, Object[] args)
throws IOException, EncryptedDocumentException {
        try {
            Class<?> clazz =
WorkbookFactory.class.getClassLoader().loadClass(factoryClass);
            Class<?>[] argsClz = new Class<?>[args.length];
            int i=0;
            for (Object o : args) {
                Class<?> c = o.getClass();
                if (Boolean.class.isAssignableFrom(c)) {
                    c = boolean.class;
                } else if (InputStream.class.isAssignableFrom(c)) {
                    c = InputStream.class;
                } else if (File.class.isAssignableFrom(c)) {
                    c = File.class;
                }
                argsClz[i++] = c;
            }
            Method m = clazz.getMethod("createWorkbook", argsClz);
            return (Workbook)m.invoke(null, args);

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63303] java.io.IOException: java.lang.NoSuchMethodException: org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(java.io.File)

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63303

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All
             Status|NEW                         |NEEDINFO

--- Comment #1 from Dominik Stadler <do...@gmx.at> ---
Sounds like you are running with different versions of Apache POI somehow,
either there is a difference between compile-time and run-time or you have
mixed versions of the various poi-jars. 

Please check your setup.

If you think this is really caused by Apache POI, please provide some
test-project which allows to reproduce this as there is no way to reproduce
this for now.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63303] java.io.IOException: java.lang.NoSuchMethodException: org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(java.io.File)

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63303

zengxh@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|1                           |0
         Resolution|INVALID                     |---
             Status|RESOLVED                    |UNCONFIRMED

--- Comment #5 from zengxh@gmail.com ---
This is still an issue.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63303] java.io.IOException: java.lang.NoSuchMethodException: org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(java.io.File)

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63303

zengxh@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|NEEDINFO                    |RESOLVED

--- Comment #4 from zengxh@gmail.com ---
Yeah how silly I was. I should have looked into the parent class.

poi 4.0.1 was the only library pulled from maven. This is the only thing I'm
sure of: there was no library version issue. I check my .m2 folder and it's the
same verdict.

I'm not able to reproduce the issue I guess we'll leave it there. Sorry about
this bug report.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63303] java.io.IOException: java.lang.NoSuchMethodException: org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(java.io.File)

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63303

--- Comment #10 from zengxh@gmail.com ---
Perhaps i was calling create(java.lang.Object pkg) method as you point out? Let
me try to give it a type hint.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63303] java.io.IOException: java.lang.NoSuchMethodException: org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(java.io.File)

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63303

zengxh@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |RESOLVED
         Resolution|---                         |INVALID

--- Comment #11 from zengxh@gmail.com ---
that's exactly the case.... i'm sorry.... i was doing a file upload in clojure
ring.

this fails
(let [file  (:tempfile req)
;;          wb    (XSSFWorkbookFactory/createWorkbook file false)
          wb    (WorkbookFactory/create file)

this works
(let [file  (:tempfile req)
;;          wb    (XSSFWorkbookFactory/createWorkbook file false)
          wb    (WorkbookFactory/create ^java.io.File file)

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63303] java.io.IOException: java.lang.NoSuchMethodException: org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(java.io.File)

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63303

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEEDINFO

--- Comment #7 from Dominik Stadler <do...@gmx.at> ---
It seems you are trying to call the WorkbookFactory.create() with a "File"
object, which is not supported. There is currently a method create(Object),
which you can call with any object, but only "OPCPackage" is supported
according to it's javadoc description. 

Also this method is scheduled to be removed in one of the next releases.

Please show the code that you use to invoke the WorkbookFactory.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63303] java.io.IOException: java.lang.NoSuchMethodException: org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(java.io.File)

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63303

--- Comment #2 from zengxh@gmail.com ---
https://poi.apache.org/apidocs/dev/org/apache/poi/xssf/usermodel/XSSFWorkbookFactory.html

Is this method createWorkbook(java.io.File) missing?
Only see this createWorkbook(java.io.File, boolean)

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63303] java.io.IOException: java.lang.NoSuchMethodException: org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(java.io.File)

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63303

--- Comment #3 from Greg Woolsey <gw...@apache.org> ---
That method only exists in the parent class,

org.apache.poi.ss.usermodel.WorkbookFactory

From the source you can see that it defaults to readOnly=false when calling 

org.apache.poi.xssf.usermodel.XSSFWorkbookFactory

Further,

org.apache.poi.xssf.usermodel.XSSFWorkbookFactory

has never implemented the method

createWorkbook(File), only ever inheriting that method from WorkbookFactory.

It's all there in the source and SVN history if you care to investigate. 

As Dominik said above, it sounds like your classpath has multiple different POI
JAR files in it.  This kind of runtime only error is almost always due to stale
JARs in the classpath and/or differences between compile and run class loading
- e.g. IDE configuration vs deployment server/container configuration.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63303] java.io.IOException: java.lang.NoSuchMethodException: org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(java.io.File)

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63303

--- Comment #9 from zengxh@gmail.com ---
I am using Clojure interop I call it essentially this way:

(WorkbookFactory/create java.io.File) which gives this

java.io.IOException: java.lang.NoSuchMethodException:
org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(java.io.File)
                     WorkbookFactory.java:354
org.apache.poi.ss.usermodel.WorkbookFactory.createWorkbook
                     WorkbookFactory.java:314
org.apache.poi.ss.usermodel.WorkbookFactory.createXSSFWorkbook
                     WorkbookFactory.java:173
org.apache.poi.ss.usermodel.WorkbookFactory.create


here's the signature:
https://poi.apache.org/apidocs/dev/org/apache/poi/ss/usermodel/WorkbookFactory.html#create-java.io.File-

examples here "Files vs InputStreams" section:
https://poi.apache.org/components/spreadsheet/quick-guide.html

perhaps a .xlsx file will trigger this according to source code and stacktrace.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org