java.io.StreamCorruptedException: invalid stream header: EFBFBDEF

大兔子大兔子 提交于 2019-12-03 05:38:23

Finally after 3 day of headache I solved my trouble. I'm using maven like tool of project managment and I'm working on a modular project with this structure

|-- parent
   |-- model
    --pom.xml
   |-- services
    --pom.xml
   |-- web-app
    --pom.xml

The porblem was that the file that I try to load like Input stream was in the src/main/resources in the services module, but in the web-app's pom.xml I enable the resource filtering, and since that web-app module depends of service the filtering was extended at the services module.

In filtering section of the maven web site Filtering I found:

Warning: Do not filter files with binary content like images! This will most likely result in corrupt output. If you have both text files and binary files as resources, you need to declare two mutually exclusive resource sets. The first resource set defines the files to be filtered and the other resource set defines the files to copy unaltered as illustrated below:

Then I removed the following code from my web-app module and everything works

<resources>
     <resource>
         <directory>src/main/resources</directory>
         <filtering>true</filtering>
    </resource>
</resources>

Thanks for this solution @skizzo

A less drastic way, if you still need to filter some other files, or copy all the files is simply to include all files you need to filter (java, xml, properties...).

Here is the solution I just implemented thanks to your help:

        <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
            <includes>
                <include>**/*.java</include>
                <include>**/*.xml</include>
                <include>**/*.properties</include>
            </includes>
        </resource>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>false</filtering>
            <excludes>
                <exclude>**/*.java</exclude>
                <exclude>**/*.xml</exclude>
                <exclude>**/*.properties</exclude>
            </excludes>
        </resource>
    </resources>

It didn't seemed related at all, and I was looking for it for several hours already. It really saved my day! ;-)

I had exactly the same problem, i was solved adding the following plug-in in my pom.xml

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>3.0.2</version>
            <configuration>
              <nonFilteredFileExtensions>
                <nonFilteredFileExtension>pdf</nonFilteredFileExtension>
                <nonFilteredFileExtension>jasper</nonFilteredFileExtension>
              </nonFilteredFileExtensions>
            </configuration>
          </plugin>

In my case, I forgot to exclude compiled jasper reports from end of line fixation ant task. For me below exclusion fixed the issue:

<fixcrlf srcdir="${basedir}/target/etc"
    includes="**/*.*"
    excludes="**/*.jasper"
    eol="lf" eof="remove"/>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!