Q:

How to fix corrupted xls file by maven?

I have a method of generating report made with jett:
    try {

        InputStream inPath = ProdutoManagedBean.class.getResourceAsStream("/template.xls");

        ExcelTransformer transformer = new ExcelTransformer();
        transformer.transform(inPath, beans);
    } catch (IOException e) {
        e.printStackTrace();
    } catch (InvalidFormatException e) {
        e.printStackTrace();
    }

I'm having an InvalidFormatException in transformer.transfom (...):
22:44:37,803 ERROR [stderr] (default task-28) org.apache.poi.openxml4j.exceptions.InvalidFormatException: Your InputStream was neither an OLE2 stream, nor an OOXML stream

I investigated that maven causes this data corruption, but I put the filter artifacts in the pom.xml and it still continues to come corrupted:
<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${compiler-plugin.version}</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <nonFilteredFileExtensions>
                        <nonFilteredFileExtension>xls</nonFilteredFileExtension>
                    </nonFilteredFileExtensions>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.5</version>
                <inherited>true</inherited>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <nonFilteredFileExtensions>
                        <nonFilteredFileExtension>xls</nonFilteredFileExtension>
                    </nonFilteredFileExtensions>
                </configuration>
            </plugin>
            <plugin>

A:

I was able to solve; I put this artifact in the pom.xml of the project that has the web infrastructure components:
 <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>3.1.0</version>
                    <inherited>true</inherited>
                    <configuration>
                        <encoding>UTF-8</encoding>
                        <nonFilteredFileExtensions>
                            <nonFilteredFileExtension>xls</nonFilteredFileExtension>
                        </nonFilteredFileExtensions>
                </plugin>
            </plugins>
        </build>

It was probably a problem caused by a specificity of the technical architecture of the project.

