UnsupportedFileFormatException while running Xls_Reader.java | Selenium Forum
M
Posted on 03/05/2016
Hi Ashish,

I am facing the below exception while running Xls_Reader.java file. I have imported all the POI API jar files to the project before running Xls_Reader.java.

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/UnsupportedFileFormatException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.TestNG.DataDriverFramewor.util.Xls_Reader.<init>(Xls_Reader.java:41)
at com.TestNG.DataDriverFramewor.util.Xls_Reader.main(Xls_Reader.java:541)
Caused by: java.lang.ClassNotFoundException: org.apache.poi.UnsupportedFileFormatException
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 14 more

Could you please let me know what is the problem?

Thanks,
Vamshi M

M
Replied on 04/05/2016

xls_reader only works for xlsx file not xls file.


M
Replied on 04/05/2016

Hi Ashish,

Yes, I'm trying to read .xlsx file only not .xls file.
But when I run the code, I'm always getting the mentioned exception.

I'm attaching the Xls_Reader.java.
Note: I have changed the .xlsx file location in the main() method.

Please let me know what went wrong here.


M
Replied on 04/05/2016

that is not how you use xls_reader.java

watch the java video to learn how create an object of a class. (module 3, 7)