Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MTA doesn't work on VSCode+OSX+OpenJDK 16.0.1 because of illegal reflection calls #73

Open
deftdawg opened this issue Oct 25, 2021 · 2 comments

Comments

@deftdawg
Copy link

dd@MBP % cd "/Users/dd/Library/Application Support/Code/User/globalStorage/redhat.mta-vscode-extension/.mta/tooling/vscode/mta-cli/mta-cli-5.2.0.Final/bin"

dd@MBP bin % java --version
openjdk 16.0.1 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-16.0.1+9 (build 16.0.1+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK-16.0.1+9 (build 16.0.1+9, mixed mode, sharing)

dd@MBP bin % ./mta-cli
Increasing the maximum of open files to 10000.
Using MTA at /Users/dd/Library/Application Support/Code/User/globalStorage/redhat.mta-vscode-extension/.mta/tooling/vscode/mta-cli/mta-cli-5.2.0.Final
MTA execution failed due to: null
java.lang.ExceptionInInitializerError
	at org.jboss.forge.furnace.proxy.javassist.util.proxy.DefineClassHelper.<clinit>(DefineClassHelper.java:216)
	at org.jboss.forge.furnace.proxy.javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:128)
	at org.jboss.forge.furnace.proxy.javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:552)
	at org.jboss.forge.furnace.proxy.javassist.util.proxy.ProxyFactory.createClass2(ProxyFactory.java:537)
	at org.jboss.forge.furnace.proxy.javassist.util.proxy.ProxyFactory.createClass1(ProxyFactory.java:473)
	at org.jboss.forge.furnace.proxy.javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:444)
	at org.jboss.forge.furnace.proxy.ClassLoaderAdapterCallback$3.call(ClassLoaderAdapterCallback.java:1044)
	at org.jboss.forge.furnace.util.ClassLoaders.executeIn(ClassLoaders.java:42)
	at org.jboss.forge.furnace.proxy.ClassLoaderAdapterCallback.enhance(ClassLoaderAdapterCallback.java:957)
	at org.jboss.forge.furnace.proxy.ClassLoaderAdapterCallback.enhance(ClassLoaderAdapterCallback.java:937)
	at org.jboss.forge.furnace.proxy.ClassLoaderAdapterBuilder.enhance(ClassLoaderAdapterBuilder.java:63)
	at org.jboss.forge.furnace.se.FurnaceFactory.getInstance(FurnaceFactory.java:68)
	at org.jboss.forge.furnace.se.FurnaceFactory.getInstance(FurnaceFactory.java:33)
	at org.jboss.windup.bootstrap.Bootstrap.run(Bootstrap.java:292)
	at org.jboss.windup.bootstrap.Bootstrap.main(Bootstrap.java:113)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @654b5005
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
	at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
	at org.jboss.forge.furnace.proxy.javassist.util.proxy.SecurityActions$3.run(SecurityActions.java:94)
	at org.jboss.forge.furnace.proxy.javassist.util.proxy.SecurityActions$3.run(SecurityActions.java:90)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:554)
	at org.jboss.forge.furnace.proxy.javassist.util.proxy.SecurityActions.getMethodHandle(SecurityActions.java:89)
	at org.jboss.forge.furnace.proxy.javassist.util.proxy.DefineClassHelper$SecuredPrivileged$2.getDefineClassMethodHandle(DefineClassHelper.java:143)
	at org.jboss.forge.furnace.proxy.javassist.util.proxy.DefineClassHelper$SecuredPrivileged$2.<init>(DefineClassHelper.java:136)
	at org.jboss.forge.furnace.proxy.javassist.util.proxy.DefineClassHelper$SecuredPrivileged.<clinit>(DefineClassHelper.java:134)
	... 15 more
@deftdawg
Copy link
Author

This issue can be worked around by applying the following to the exec call in mta-cli

--add-opens java.base/java.lang=ALL-UNNAMED

So the line looks like this:

exec "$JAVACMD" $MODULES "${MTA_DEBUG_ARGS[@]}" $MTA_OPTS --add-opens java.base/java.lang=ALL-UNNAMED -Dforge.standalone=true -Dforge.home="${MTA_HOME}" -Dwindup.home="${MTA_HOME}" \
   -cp "${MTA_HOME}"/lib/'*' $MTA_MAIN_CLASS "${QUOTED_ARGS[@]}" "${ADDONS_DIR[@]}"

@deftdawg
Copy link
Author

Related to this once you get past the initial reflection errors there's another ... must add this also:

--add-opens java.base/java.util=ALL-UNNAMED

error:

Migration Toolkit for Applications (MTA) CLI, version [ 5.2.0.Final ] - by Red Hat, Inc. [ https://developers.redhat.com/products/mta/overview/ ]

Failed to start MTA!
java.lang.RuntimeException: Could not retrieve ClassLoader whitelist from callback [org.jboss.forge.furnace.se.FurnaceFactory$1@62e136d3].
	at org.jboss.forge.furnace.proxy.ClassLoaderAdapterCallback.whitelistContainsAll(ClassLoaderAdapterCallback.java:638)
	at org.jboss.forge.furnace.proxy.ClassLoaderAdapterCallback.enhance(ClassLoaderAdapterCallback.java:948)
	at org.jboss.forge.furnace.proxy.ClassLoaderAdapterCallback.enhanceResult(ClassLoaderAdapterCallback.java:252)
	at org.jboss.forge.furnace.proxy.ClassLoaderAdapterCallback.access$200(ClassLoaderAdapterCallback.java:38)
	at org.jboss.forge.furnace.proxy.ClassLoaderAdapterCallback$2.call(ClassLoaderAdapterCallback.java:125)
	at org.jboss.forge.furnace.util.ClassLoaders.executeIn(ClassLoaders.java:42)
	at org.jboss.forge.furnace.proxy.ClassLoaderAdapterCallback.invoke(ClassLoaderAdapterCallback.java:97)
	at org.jboss.forge.furnace.proxy.javassist.util.proxy.java_util_concurrent_Future_$$_jvst73b_2.get(java_util_concurrent_Future_$$_jvst73b_2.java)
	at org.jboss.windup.bootstrap.commands.windup.ToolingModeCommand.execute(ToolingModeCommand.java:58)
	at org.jboss.windup.bootstrap.Bootstrap.toolingMode(Bootstrap.java:545)
	at org.jboss.windup.bootstrap.Bootstrap.main(Bootstrap.java:111)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make public final boolean java.util.HashMap$HashIterator.hasNext() accessible: module java.base does not "opens java.util" to unnamed module @530612ba
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
	at java.base/java.lang.reflect.AccessibleObject.setAccessible(AccessibleObject.java:130)
	at org.jboss.forge.furnace.proxy.ClassLoaderAdapterCallback$2.call(ClassLoaderAdapterCallback.java:120)
	at org.jboss.forge.furnace.util.ClassLoaders.executeIn(ClassLoaders.java:42)
	at org.jboss.forge.furnace.proxy.ClassLoaderAdapterCallback.invoke(ClassLoaderAdapterCallback.java:97)
	at org.jboss.forge.furnace.proxy.javassist.util.proxy.java_util_Iterator_$$_jvst73b_5.hasNext(java_util_Iterator_$$_jvst73b_5.java)
	at org.jboss.forge.furnace.se.FurnaceFactory$1.call(FurnaceFactory.java:85)
	at org.jboss.forge.furnace.se.FurnaceFactory$1.call(FurnaceFactory.java:71)
	at org.jboss.forge.furnace.proxy.ClassLoaderAdapterCallback.whitelistContainsAll(ClassLoaderAdapterCallback.java:628)
	... 10 more
Calling ToolingModeRunner...
Using Data:
input: [/Users/dd/projects/hlink-web/HLinkWeb]
output: /Users/dd/Library/Application Support/Code/User/globalStorage/redhat.mta-vscode-extension/.mta/tooling/vscode/7ss1bqtb0-i7i5a7u05
sourceMode: true
skipReport: false
ignorePatterns: []
windupHome: /Users/dd/Library/Application Support/Code/User/globalStorage/redhat.mta-vscode-extension/.mta/tooling/vscode/mta-cli/mta-cli-5.2.0.Final
source: [websphere, java, log4j, oraclejdk]
target: [cloud-readiness, openjdk, linux]
userRulesDirectory: []
MTA execution failed due to: No services of type [org.jboss.windup.tooling.ToolingModeRunner] could be found in any started addons.
org.jboss.forge.furnace.exception.ContainerException: No services of type [org.jboss.windup.tooling.ToolingModeRunner] could be found in any started addons.
	at org.jboss.forge.furnace.impl.addons.ImportedImpl.get(ImportedImpl.java:79)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at org.jboss.forge.furnace.proxy.ClassLoaderAdapterCallback$2.call(ClassLoaderAdapterCallback.java:124)
	at org.jboss.forge.furnace.util.ClassLoaders.executeIn(ClassLoaders.java:42)
	at org.jboss.forge.furnace.proxy.ClassLoaderAdapterCallback.invoke(ClassLoaderAdapterCallback.java:97)
	at org.jboss.forge.furnace.services.Imported_$$_jvst73b_6.get(Imported_$$_jvst73b_6.java)
	at org.jboss.windup.bootstrap.commands.windup.ToolingModeCommand.analyze(ToolingModeCommand.java:130)
	at org.jboss.windup.bootstrap.commands.windup.ToolingModeCommand.execute(ToolingModeCommand.java:65)
	at org.jboss.windup.bootstrap.Bootstrap.toolingMode(Bootstrap.java:545)
	at org.jboss.windup.bootstrap.Bootstrap.main(Bootstrap.java:111)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant