1

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>
philabreu
  • 55
  • 1
  • 7
  • 1
    The configurations for the maven-jar-plugin are useless cause those configuration elements do not exist in [maven-jar-plugin](https://maven.apache.org/plugins/maven-jar-plugin/jar-mojo.html). Have you checked that the original file is correct? – khmarbaise Sep 06 '17 at 06:42
  • Seems as if the maven users leave you in the lurch. So some hints from one who is a explicit maven hater ;-): You should read about the best practice way to provide resources in maven. And no, this is not putting them into the jar alongside the classes. Your "nonFilteredFileExtension" will only works in maven-resources-plugin, which is recommened to use. The maven-compiler-plugin provides only "excludes". – Axel Richter Sep 07 '17 at 09:44

1 Answers1

1

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.

philabreu
  • 55
  • 1
  • 7