Tibor Digana created SUREFIRE-1702:
--------------------------------------
Summary: [JDK 11 Alpine Linux] JAR content is not flushed
completely down to drive "Error: Invalid or corrupt jarfile
target/surefire/surefirebooter13749914711390838584.jar"
Key: SUREFIRE-1702
URL: https://issues.apache.org/jira/browse/SUREFIRE-1702
Project: Maven Surefire
Issue Type: Improvement
Components: Maven Failsafe Plugin, Maven Surefire Plugin, process
forking
Reporter: Tibor Digana
Fix For: 3.0.0-M4
We found an [error with a corrupted JAR
file|http://ldytyk.blogspot.com/2019/03/maven-tests-fail-with-forked-vm.html]
published by our users. They used Docker image
{{adoptopenjdk/openjdk11:jdk-11.0.2.9-alpine}} and reproduced the error by the
project [on GitHub|https://github.com/mxxk/mvn-surefire-plugin-failure].
The plugin failure only occures when:
* using Surefire's mode of forking a new JVM (the default behavior); and
* On Docker image based on Alpine Linux. It does not reproduce on an image
based on Ubuntu.
I checked some errors regarding Surefire on Alpine images and I found that the
plugin crashed immediately.
{noformat}
/app # java -jar target/surefire/surefirebooter13749914711390838584.jar
Error: Invalid or corrupt jarfile
target/surefire/surefirebooter13749914711390838584.jar
{noformat}
then I decided to extract the file
{noformat}
/app # unzip target/surefire/surefirebooter13749914711390838584.jar -d extracted
{noformat}
the manifest file has incomplete content:
{noformat}
cat extracted/META-INF/MANIFEST.MF
Manifest-Version: 1.0
Class-Path: ../../../root/.m2/repository/org/apache/maven/surefire/suref
ire-booter/3.0.0-SNAPSHOT/surefire-booter-3.0.0-SNAPSHOT.jar ../../../r
oot/.m2/repository/org/apache/maven/surefire/surefire-api/3.0.0-SNAPSHO
T/surefire-api-3.0.0-SNAPSHOT.jar ../../../root/.m2/repository/org/apac
he/maven/surefire/surefire-logger-api/3.0.0-SNAPSHOT/surefire-logger-ap
i-3.0.0-SNAPSHOT.jar ../test-classes/ ../classes/ ../../../root/.m2/rep
ository/org/junit/jupiter/junit-jupiter-
{noformat}
If you zip the same again {{/app # jar cvf MyJar.jar extracted/.}} and start
the new JAR file separately:
{noformat}
/app # java -jar MyJar.jar
Picked up JAVA_TOOL_OPTIONS:
no main manifest attribute, in MyJar.jar
{noformat}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)