java.io.StreamCorruptedException: invalid stream header: EFBFBDEF

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! ;-)


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>