Error after upgrading from Apache Poi 4.1.2 to 5.2.3

404 Views Asked by At

After upgrading to from Apache Poi 4.1.2 to 5.2.3 I got this error:

java.io.IOException: Your InputStream was neither an OLE2 stream, nor an OOXML stream or you haven't provide
the poi-ooxml*.jar in the classpath/modulepath - FileMagic: OOXML, having providers:org.apache.poi.hssf.usermodel.HSSFWorkbookFactory@4681c175]

after a search I found this can be fixed with maven build plugin maven-shade-plugin by adding a transformer in pom.xml:

<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>

As I am using maven-assembly-plugin, Is there any way that I can achieve this with maven-assembly-plugin

This is my maven-assembly-plugin configuration in pom.xml

        <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <appendAssemblyId>false</appendAssemblyId>
                    <archive>
                        <manifest>
                            <mainClass>test.poitest.Program</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
0

There are 0 best solutions below