aadarchi icon indicating copy to clipboard operation
aadarchi copied to clipboard

Build fail when using Java 17

Open Riduidel opened this issue 4 years ago • 7 comments

When trying to build on Java 17, we all get those exceptions Could not initialize class cucumber.deps.com.thoughtworks.xstream.converters.collections.TreeMapConverter

Riduidel avatar Mar 03 '22 15:03 Riduidel

Seems interesting, no? https://github.com/cucumber-attic/cucumber-jvm-deps/issues/6

Riduidel avatar Mar 03 '22 15:03 Riduidel

on my side the error on java 17 was : java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @6ee417d8

sebvelay avatar May 23 '22 14:05 sebvelay

Yeah, if you want to spend some time making things work on new Java version, I would be very happy. But for me, all that module fuckery is really awful

Riduidel avatar May 23 '22 14:05 Riduidel

Hello! I'm using version 17 of java to run my tests, and the error I'm getting is this:

java.lang.ExceptionInInitializerError
at cucumber.deps.com.thoughtworks.xstream.XStream.setupConverters(XStream.java:820)

Is this going to be fixed at some point? Because the tests only work for me when I use java 1.8, and I need to use my own library that uses java 17, can someone help me? I have also tried adding this in the pom:

<dependency>
                 <groupId>io.cucumber</groupId>
                 <artifactId>cucumber-jvm</artifactId>
                 <version>7.3.4</version>
                 <type>pom</type>
             <exclusions>
                 <exclusion>
                     <groupId>io.cucumber</groupId>
                     <artifactId>cucumber-jvm-deps</artifactId>
                 </exclusion>
             </exclusions>
         </dependency>

But it still doesn't work, can someone help me?

BeatrizLo avatar Jun 08 '22 21:06 BeatrizLo

Hello @BeatrizLo I'm happy you're trying to use our project! The problem you've seen seems to come from cucumber (quite sure this is a repackaging of xstream through some kind of shading - like what the maven-shade-plugin does).

Can you confirm it is the same stack trace than in this stackoverflow question ?

Unfortunatly, I can find no public support forum for cucumber, so I can't investigate any further. Anyway, yes, we have some troubles regarding java 17, but unfortunatly for you this one directly come from Cucumber.

Riduidel avatar Jun 09 '22 06:06 Riduidel

Found this while searching for the same error in our products. Thought I should share the solution I found at https://stackoverflow.com/questions/69753263/unable-to-make-field-final-transient-java-lang-class-java-util-enumset-elementty

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemPropertyVariables>
                        <buildDirectory>${project.build.directory}</buildDirectory>
                    </systemPropertyVariables>
                    <testFailureIgnore>true</testFailureIgnore>
                    <argLine>
                        --add-opens java.base/java.lang=ALL-UNNAMED
                        --add-opens java.base/java.util=ALL-UNNAMED
                        --add-opens java.base/java.lang.reflect=ALL-UNNAMED
                        --add-opens java.base/java.text=ALL-UNNAMED
                        --add-opens java.desktop/java.awt.font=ALL-UNNAMED
                    </argLine>
                </configuration>
            </plugin>

jhedin-csam avatar Oct 26 '22 07:10 jhedin-csam

Facing similar kind of issue, but adding the plugin in pom doesn't help.

Amity007 avatar Apr 17 '23 16:04 Amity007