Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/POIXMLTypeLoader
at org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook$Factory.newInstance(Unknown Source)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.onWorkbookCreate(XSSFWorkbook.java:452)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:255)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:249)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:237)
at com.dandylabs.DandyLabsGalleryViewsXLSGenerator.createHeader(DandyLabsGalleryViewsXLSGenerator.java:126)
at com.dandylabs.DandyLabsGalleryViewsXLSGenerator.toXLS(DandyLabsGalleryViewsXLSGenerator.java:324)
at com.dandylabs.DandyLabsGalleryViewsXLSGenerator.perform(DandyLabsGalleryViewsXLSGenerator.java:259)
at com.dandylabs.DandyLabsGalleryViewsXLSGenerator.main(DandyLabsGalleryViewsXLSGenerator.java:359)
Caused by: java.lang.ClassNotFoundException: org.apache.poi.POIXMLTypeLoader
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 9 more
Carey Brown wrote:This worked for me so I suspect DandyLabs. What is that?
What jar files were you obligated to include in your classpath?
Phillip Powell wrote:
Carey Brown wrote:This worked for me so I suspect DandyLabs. What is that?
What jar files were you obligated to include in your classpath?
Because I am including a plethora of Apache POI jar files, and it still never seems enough. If I use HSSFWorkbook instead of XSSFWorkbook, things work better, but otherwise I get this error, and I have this class in my poi-5.0.0.jar file:
Caused by: java.lang.ClassNotFoundException: org.apache.poi.POIXMLTypeLoader
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 8 more
Stack Overflow wrote:... it seems that in new versions of Apache POI, a reference to org.apache.poi.POIXMLTypeLoader persists, in new versions this class was moved to org.apache.poi.ooxml.POIXMLTypeLoader...
Carey Brown wrote:commons-collections4-4.1.jar
poi-3.17.jar
poi-3.8-20120326.jar
poi-ooxml-3.17.jar
poi-ooxml-schemas-3.17.jar
xmlbeans-5.1.3.jar
granted these are somewhat dated
Paul Clapham wrote:One post I found elsewhere said
Stack Overflow wrote:... it seems that in new versions of Apache POI, a reference to org.apache.poi.POIXMLTypeLoader persists, in new versions this class was moved to org.apache.poi.ooxml.POIXMLTypeLoader...
However, if you're using an IDE then usually it will tell you that "POIXMLTypeLoader" isn't imported (remove its import statement) and you can click something to have it find the correct package from the classpath.
class org.apache.poi.hssf.usermodel.HSSFPatriarch cannot be cast to class org.apache.poi.xssf.usermodel.XSSFDrawing (org.apache.poi.hssf.usermodel.HSSFPatriarch and org.apache.poi.xssf.usermodel.XSSFDrawing are in unnamed module of loader 'app')
Carey Brown wrote:I did swap in "DEFAULT_TYPE_NAME". Don't know what difference that would have made.
Phillip Powell wrote:... and yet I am riddled with NoClassDefFoundError for everything from com.zaxxer.sparsebits.SparseBitSet to POIXMLTypeLoader to whatever happens next..
Paul Clapham wrote:
Phillip Powell wrote:... and yet I am riddled with NoClassDefFoundError for everything from com.zaxxer.sparsebits.SparseBitSet to POIXMLTypeLoader to whatever happens next..
But this just sounds like your classpath hasn't been set correctly (or at all).
commons-collections4-4.3.jar
commons-compress-1.26.1.jar
dom4j-1.6.jar
HikariCP-5.1.0.jar
poi-5.0.0.jar
poi-ooxml-5.0.0.jar
poi-ooxml-schemas-3.6.jar
slf4j-api-1.7.36.jar
SparseBitSet-1.3.jar
stax-api-1.0.1.jar
xml-apis-1.4.01.wso2v1.jar
xmlbeans-5.2.0.jar
Phillip Powell wrote:I am using Eclipse
Good. Then delete all of the import statements from your code. This will produce red lines under all of those POI classes. Hovering over the red lines will produce a drop-down which may include the option to add an import statement for the class. If there are two such options then you may have too much stuff in your classpath, and if there are none then your classpath needs the jar file which has that class. Or else its name is misspelled.
Caused by: java.lang.ClassNotFoundException: org.apache.poi.POIXMLTypeLoader
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 8 more
Stack Overflow wrote:... it seems that in new versions of Apache POI, a reference to org.apache.poi.POIXMLTypeLoader persists, in new versions this class was moved to org.apache.poi.ooxml.POIXMLTypeLoader...
Paul Clapham wrote:
Stack Overflow wrote:... it seems that in new versions of Apache POI, a reference to org.apache.poi.POIXMLTypeLoader persists, in new versions this class was moved to org.apache.poi.ooxml.POIXMLTypeLoader...
So it looks like that could be a problem in the POI jars themselves. I'm using poi-4.1.2.jar and poi-ooxml-4.1.2.jar and poi-ooxml-schemas-4.1.2.jar myself, installed in my system in March 2020, with no problems. Maybe you could try those?
(I update my OSS jars periodically, but not that often. I updated Commons CSV last year and that was a pain because they improved the design and I had to change my code to match their changes. And they didn't improve the documentation to match.)
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.poi.util.DocumentHelper (file:/C:/Users/phill/OneDrive/Desktop/jar/poi-ooxml-3.17.jar) to constructor com.sun.org.apache.xerces.internal.util.SecurityManager()
WARNING: Please consider reporting this to the maintainers of org.apache.poi.util.DocumentHelper
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
poi-3.17.jar
poi-ooxml-3.17.jar
poi-ooxml-schemas-3.17.jar
xmlbeans-2.3.0.jar
Paul Clapham wrote:In Java 9 the "reflection" access methods were restricted as part of the "modularization" of Java. So far, this just produces warnings, which are designed to prompt you to fix your code to do reflection differently.
Java 9 Illegal Reflective Access Warning
It's not your code so you can't do anything , except to upgrade to the later version in which this issue has presumably been fixed. Catch-22! But your other option is to ignore the warnings.
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |