0

I have updated in a project the version of apache.poi from 3.9.0 to 5.0.0.

build.gradle

implementation 'org.apache.poi:poi:5.0.0'
implementation 'org.apache.poi:poi-ooxml:5.0.0'

I use that library to generate Excel files dynamically on the server and locally with tomcat everything worked correctly.

When I uploaded the project to the production server (Weblogic) I'm facing with the following error:

"Could not initialize class org.apache.poi.xssf.model.SharedStringsTable"

From what I read, it may be some incompatibility of Weblogic with an xmlbean jar

Does someone have any idea of ​​what it can be?

vcima
  • 421
  • 1
  • 7
  • 20
  • You could look for previous stackoverflow questions - eg https://stackoverflow.com/questions/72930783/apache-poi-and-weblogic-jar-conflict-poi-5-and-xmlbeans - you could also contact Weblogic support – PJ Fanning Oct 12 '22 at 10:36
  • @vcima Were you able to overcome this ? – DKG Dec 07 '22 at 06:59
  • @DKG. Yes, I leave you the solution that I found below. Hope this can help you – vcima Dec 08 '22 at 09:41

1 Answers1

1

Finally I have solved this problem including a new file.

webapp > WEB-INF > weblogic.xml

<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
  xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_2.xsd
http://xmlns.oracle.com/weblogic/weblogic-web-app
http://xmlns.oracle.com/weblogic/weblogic-web-app/1.9/weblogic-web-app.xsd">
    <context-root>/</context-root>
    <weblogic-version>14.1.1</weblogic-version>
    <wls:container-descriptor>
        <wls:prefer-application-packages>
            <wls:package-name>org.apache.commons.*</wls:package-name>
            <wls:package-name>org.apache.poi.*</wls:package-name>
            <wls:package-name>org.apache.xmlbeans.*</wls:package-name>
            <wls:package-name>org.openxmlformats.*</wls:package-name>
            <wls:package-name>schemaorg_apache_xmlbeans.*</wls:package-name>
        </wls:prefer-application-packages>
        <prefer-application-resources>
            <resource-name>schemaorg_apache_xmlbeans/system/sXMLCONFIG/TypeSystemHolder.class</resource-name>
            <resource-name>schemaorg_apache_xmlbeans/system/sXMLLANG/TypeSystemHolder.class</resource-name>
            <resource-name>schemaorg_apache_xmlbeans/system/sXMLSCHEMA/TypeSystemHolder.class</resource-name>
            <resource-name>schemaorg_apache_xmlbeans/system/sXMLTOOLS/TypeSystemHolder.class</resource-name>
        </prefer-application-resources>
    </wls:container-descriptor>
</wls:weblogic-web-app>
vcima
  • 421
  • 1
  • 7
  • 20