Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
383 views
in Technique[技术] by (71.8m points)

java - jar file gets corrupted while building with maven

while building a war file i am copying a set of jars from a location to a folder inside the war. While the files do get copied , however i think they get corrupted because the same class files of the jar when taken outside the war opens with a debugger while it does not open after taking from war file .

This is a part of my war pom.xml where i copy the jars

<execution> 
    <id>copy-jars</id> 
    <phase>process-resources</phase> 
    <goals> 
        <goal>copy-resources</goal> 
    </goals> 
    <configuration> 
        <outputDirectory>${basedir}/target/${project.artifactId}-${buildNumber}/somefolder</outputDirectory> 
         <resources> 
            <resource> 
                <directory>SomeSourceDirectory</directory> 
                <filtering>true</filtering> 
                <includes> 
                    <include>**/**</include> 
                </includes>
            </resource>
        </resources> 
    </configuration> 
</execution>

SomeSourceDirectory has some jars and some other files The result is: myWar/somefolder/a.jar but when i open the classes inside this jar in a debugger..i get error in WinZip that

Invalid compressed data to extract.
Severe Error:  Compressed data is invalid

However the same class file can be viewed when i view it in original folder i.e outside the war. So is there a mistake while copying the jars? Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Remove <filtering>true</filtering>, it corrupts the jar files.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...