payara / ecosystem-support

Placeholder repository to handle community requests for the Payara Platform ecosystem tools
3 stars 2 forks source link

Bug Report: ecosystem-arquillian-connectors/environment-setup uses illegal reflective access #30

Closed poikilotherm closed 2 years ago

poikilotherm commented 3 years ago

Description


Using this handy extension prints a warning about an illegal reflective access operation has occurred.

Expected Outcome

No warning.

Current Outcome

image

[ERROR] WARNING: Illegal reflective access by fish.payara.arquillian.environment.setup.EnviromentRemoteExtension$EnvironmentSetter (file:/home/obertuch/.m2/repository/fish/payara/arquillian/environment-setup/2.4.3/environment-setup-2.4.3.jar) to field java.util.Collections$UnmodifiableMap.m

Sample Project (Optional)

  1. Goto https://github.com/poikilotherm/reproducer-payara-mpconfig-seturl and clone
  2. Use mvn -Parq-payara-managed verify to execute integration test using Arquillian Payara Managed.

:mega: Shoutout and kudos to @lprimak for the handy extension :pray:

Environment

lprimak commented 3 years ago

Thanks for the kudos. Not tested, but you can use MAVEN_OPTS environment variable to o set up appropriate Java options to remove the warning. I see no other way around it

lprimak commented 3 years ago

See https://stackoverflow.com/questions/59510941/how-to-set-environment-variable-in-java-without-illegal-reflective-access-how

MeroRai commented 2 years ago

Hi @poikilotherm,

Were you able to test the suggestion made by Lenny?

poikilotherm commented 2 years ago

Nope, not yet.

That warning isn't very specific about where that illegal access happens... But maybe there is a way to fix the code?

From the code there are multiple places that access to an unmodifiable list might happen. 🤔

lprimak commented 2 years ago

There is no way to “fix” this in the code. The only way to remove the warning is to do what’s suggested above

lprimak commented 2 years ago

The stack overflow link has the exact suggestion on how to fix this

poikilotherm commented 2 years ago

Thx @lprimak, I did mean no offense.

After digging a bit more into this, at least I can show some more debug output: grafik

I see why there is no way around this. As this happened during a Maven Failsafe test, MAVEN_OPTS cannot be used. You need to either any JVM args via argLine in plugin config or via user property:

mvn -DargLine="--illegal-access=debug" -Parq-payara-managed verify

(This could also be provided within .mvn/maven.config as of Maven 3.3+)

To finally resolve the issue you'd use:

mvn -DargLine="--add-opens=java.base/java.util=ALL-UNNAMED" -Parq-payara-managed verify

(Or add this to the plugin config / .mvn/maven.config)

lprimak commented 2 years ago

No offense taken. You can add the same argLine to MAVEN_OPTS no? That’s what I was hinting att

poikilotherm commented 2 years ago

Aye, MAVEN_OPTS="-DargLine=--illegal-access=debug --add-opens=java.base/java.util=ALL-UNNAMED" mvn -Parq-payara-managed verify does the trick, too.

Also I like more the beauty of a short CLI call and providing it via config:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>${maven-failsafe-plugin.version}</version>
    <configuration>
        <argLine>--illegal-access=debug --add-opens=java.base/java.util=ALL-UNNAMED</argLine>
        <systemPropertyVariables>
            <payara.home>${project.build.directory}/payara5</payara.home>
        </systemPropertyVariables>
    </configuration>
</plugin>