1

I am getting the below error when exporting excel using POI 5 with xmlbeans 4.

Root cause of ServletException.

java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at  org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl.build(SchemaTypeLoaderImpl.java:161)
at org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.<init>(SchemaTypeSystemImpl.java:168)
at org.apache.xmlbeans.metadata.system.sXMLSCHEMA.TypeSystemHolder.<init>(TypeSystemHolder.java:41)
Truncated. see log file for complete stacktrace

Caused By: org.apache.xmlbeans.XmlRuntimeException: java.lang.ClassCastException: org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl cannot be cast to org.apache.xmlbeans.SchemaTypeLoader
at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl.build(SchemaTypeLoaderImpl.java:164)
at org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.<init>(SchemaTypeSystemImpl.java:168)
at org.apache.xmlbeans.metadata.system.sXMLTOOLS.TypeSystemHolder.<init>(TypeSystemHolder.java:41)
at org.apache.xmlbeans.metadata.system.sXMLTOOLS.TypeSystemHolder.<clinit>(TypeSystemHolder.java:44)
at java.lang.Class.forName0(Native Method)
Truncated. see log file for complete stacktrace

Caused By: java.lang.ClassCastException: org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl cannot be cast to org.apache.xmlbeans.SchemaTypeLoader
at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl.build(SchemaTypeLoaderImpl.java:162)
at org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.<init>(SchemaTypeSystemImpl.java:168)
at org.apache.xmlbeans.metadata.system.sXMLTOOLS.TypeSystemHolder.<init>(TypeSystemHolder.java:41)
at org.apache.xmlbeans.metadata.system.sXMLTOOLS.TypeSystemHolder.<clinit>(TypeSystemHolder.java:44)
at java.lang.Class.forName0(Native Method)
Truncated. see log file for complete stacktrace

I have checked that my xmlbeans come from xmlbeans-4.0.0.jar and the ooxml-schema has been removed and replaced with poi-ooxml-full-5.0.0.jar

What may went wrong?

Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220
Min
  • 11
  • 1
  • 4

1 Answers1

1

The classes of xmlbeans getting loaded can be of wrong version. If you can check the classloader for the version of xmlbeans. Servers like weblogic have older version of xmlbeans which can cause conflict

  • Hi Raj, Thanks. I managed to trace the class references and found out that there is a reference to a folder in the previous version of xmlbeans. After extracting that folder out and put in my library list it can work. – Min Mar 01 '21 at 01:34
  • See also https://stackoverflow.com/questions/67309369/apache-poi-5-and-xmlbeans-classpath-issues – PJ Fanning Sep 06 '21 at 16:07