spotify / dockerfile-maven

MATURE: A set of Maven tools for dealing with Dockerfiles
Apache License 2.0
2.75k stars 493 forks source link

"java.lang.ExceptionInInitializerError ... java.lang.ArrayIndexOutOfBoundsException: 1 at org.codehaus.plexus.archiver.zip.AbstractZipArchiver" when using Java 9 #163

Closed kamilgregorczyk closed 6 years ago

kamilgregorczyk commented 6 years ago

Hi everyone, I'm using spring boot 2.0 with java 9. I wanted to use this plugin but without any luck so far. When I'm calling: mvn dockerfile:build I get nulls (java.lang.ExceptionInInitializerError: null)

Here's my full error: https://pastebin.com/BZwmHMrB Full error with debug flag (-e -X): https://pastebin.com/rvyiEz1h

Here's my POM file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.posts</groupId>
    <artifactId>posts</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>posts</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>9</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.16.20</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>dockerfile-maven-plugin</artifactId>
                <version>1.4.0</version>
                <executions>
                    <execution>
                        <id>default</id>
                        <goals>
                            <goal>build</goal>
                            <goal>push</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <repository>uniqe15/posts</repository>
                    <tag>${project.version}</tag>
                    <buildArgs>
                        <JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
                    </buildArgs>
                </configuration>
            </plugin>

        </plugins>
    </build>

</project>

Here's my mvn -v

Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-24T20:49:05+01:00)
Maven home: /usr/local/Cellar/maven/3.5.3/libexec
Java version: 9, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
Default locale: pl_PL, platform encoding: UTF-8
OS name: "mac os x", version: "10.13.3", arch: "x86_64", family: "Mac"
mattnworb commented 6 years ago

Thanks for the report. In the future, please post the exception messages / output in the issue itself, as anyone searching for similar issues on Github in the future won't be able to find anything behind a pastebin link.

This seems to be the relevant part of the stacktrace:

Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
    at org.codehaus.plexus.archiver.zip.AbstractZipArchiver.<clinit> (AbstractZipArchiver.java:116)
    at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method)
    at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance (Constructor.java:488)

From searching for that class and exception, I found https://github.com/mojohaus/nbm-maven-plugin/issues/24 which pointed me towards https://cwiki.apache.org/confluence/display/MAVEN/Java+9+-+Jigsaw - it seems like a fair number of core Maven plugins are not yet ready for Java 9, or require updates to the version that this library pulls in in order to be compatible.

mattnworb commented 6 years ago

in particular some of these dependencies might need updating to Java 9 compatible versions: https://github.com/spotify/dockerfile-maven/blob/v1.4.0/plugin/pom.xml#L54-L82

kamilgregorczyk commented 6 years ago

Thanks for your response, I assume no quick fix is possible?

mattnworb commented 6 years ago

I haven't looked into it yet besides the comments above. We aren't using Java 9 ourselves much yet, so might not have an opportunity to figure it out right away - would definitely welcome any PRs or more investigation here. I'd start with trying to find the latest versions of the mentioned dependencies.

Laures commented 6 years ago

i had the same stacktrace, following the advice from another issue fixed everything for me https://github.com/spotify/dockerfile-maven/issues/77

tl;dr: add the following to your plugin configuration

                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.plexus</groupId>
                        <artifactId>plexus-archiver</artifactId>
                        <version>3.4</version>
                    </dependency>
                    <dependency>
                        <groupId>javax.activation</groupId>
                        <artifactId>javax.activation-api</artifactId>
                        <version>1.2.0</version>
                    </dependency>
                </dependencies>
stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

mattnworb commented 6 years ago

this isn't stale; the comment in https://github.com/spotify/dockerfile-maven/issues/163#issuecomment-379775227 should fix it, someone just needs to make a PR

mattnworb commented 6 years ago

docker-client also needs to be updated to work with Java 9+, see https://github.com/spotify/docker-client/pull/1068

mattnworb commented 6 years ago

Did not realize this was already reported in #77, but this can be closed now too: see https://github.com/spotify/dockerfile-maven/issues/77#issuecomment-427489783