graal icon indicating copy to clipboard operation
graal copied to clipboard

Could not initialize class org.graalvm.polyglot.Engine$ImplHolder

Open ljy1058318852 opened this issue 1 year ago • 8 comments

ERROR:

java.lang.IllegalAccessError: superclass access check failed: class com.oracle.truffle.polyglot.PolyglotImpl (in unnamed module @0x559dfc35) cannot access class org.graalvm.polyglot.impl.AbstractPolyglotImpl (in module org.graalvm.polyglot) because module org.graalvm.polyglot does not export org.graalvm.polyglot.impl to unnamed module @0x559dfc35
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
	at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:534)
	at java.base/java.lang.Class.forName(Class.java:513)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(ServiceLoader.java:1217)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1228)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1273)
	at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1309)
	at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1393)
	at org.graalvm.polyglot/org.graalvm.polyglot.Engine.loadAndValidateProviders(Engine.java:1627)
	at org.graalvm.polyglot/org.graalvm.polyglot.Engine$1.run(Engine.java:1712)
	at org.graalvm.polyglot/org.graalvm.polyglot.Engine$1.run(Engine.java:1707)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:319)
	at org.graalvm.polyglot/org.graalvm.polyglot.Engine.initEngineImpl(Engine.java:1707)
	at org.graalvm.polyglot/org.graalvm.polyglot.Engine$ImplHolder.<clinit>(Engine.java:190)
	at org.graalvm.polyglot/org.graalvm.polyglot.Engine.getImpl(Engine.java:442)
	at org.graalvm.polyglot/org.graalvm.polyglot.Engine$Builder.build(Engine.java:740)
	at org.graalvm.polyglot/org.graalvm.polyglot.Context$Builder.build(Context.java:1925)
	at org.graalvm.polyglot/org.graalvm.polyglot.Context.create(Context.java:979)
	at [email protected]/com.potato.potatotool.utils.DeserializerUtils.serializeParsing(DeserializerUtils.java:22)
	at [email protected]/com.potato.potatotool.utils.DeserializerUtils.serializeCheck(DeserializerUtils.java:71)
	at [email protected]/com.potato.potatotool.utils.aesUtils.decrypt(aesUtils.java:164)
	at [email protected]/com.potato.potatotool.content.blueTeam.casDecrypt.decrypt(casDecrypt.java:46)
	at [email protected]/com.potato.potatotool.content.blueTeam.webShellDecrypt.bodyDecrypt(webShellDecrypt.java:218)
	at [email protected]/com.potato.potatotool.content.blueTeam.webShellDecrypt.dealBody(webShellDecrypt.java:114)
	at [email protected]/com.potato.potatotool.controller.PaneWebshellDecode$3.call(PaneWebshellDecode.java:348)
	at [email protected]/com.potato.potatotool.controller.PaneWebshellDecode$3.call(PaneWebshellDecode.java:341)
	at [email protected]/javafx.concurrent.Task$TaskCallable.call(Task.java:1399)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base/java.lang.Thread.run(Thread.java:1583)
java.lang.NoClassDefFoundError: Could not initialize class org.graalvm.polyglot.Engine$ImplHolder
	at org.graalvm.polyglot/org.graalvm.polyglot.Engine.getImpl(Engine.java:442)
	at org.graalvm.polyglot/org.graalvm.polyglot.Engine$Builder.build(Engine.java:740)
	at org.graalvm.polyglot/org.graalvm.polyglot.Context$Builder.build(Context.java:1925)
	at org.graalvm.polyglot/org.graalvm.polyglot.Context.create(Context.java:979)
	at [email protected]/com.potato.potatotool.utils.DeserializerUtils.serializeParsing(DeserializerUtils.java:22)
	at [email protected]/com.potato.potatotool.utils.DeserializerUtils.serializeCheck(DeserializerUtils.java:71)
	at [email protected]/com.potato.potatotool.utils.aesUtils.decrypt(aesUtils.java:164)
	at [email protected]/com.potato.potatotool.content.blueTeam.casDecrypt.decrypt(casDecrypt.java:46)
	at [email protected]/com.potato.potatotool.content.blueTeam.webShellDecrypt.bodyDecrypt(webShellDecrypt.java:218)
	at [email protected]/com.potato.potatotool.content.blueTeam.webShellDecrypt.dealBody(webShellDecrypt.java:114)
	at [email protected]/com.potato.potatotool.controller.PaneWebshellDecode$3.call(PaneWebshellDecode.java:348)
	at [email protected]/com.potato.potatotool.controller.PaneWebshellDecode$3.call(PaneWebshellDecode.java:341)
	at [email protected]/javafx.concurrent.Task$TaskCallable.call(Task.java:1399)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.IllegalAccessError: superclass access check failed: class com.oracle.truffle.polyglot.PolyglotImpl (in unnamed module @0x559dfc35) cannot access class org.graalvm.polyglot.impl.AbstractPolyglotImpl (in module org.graalvm.polyglot) because module org.graalvm.polyglot does not export org.graalvm.polyglot.impl to unnamed module @0x559dfc35 [in thread "Thread-5"]
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
	at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:534)
	at java.base/java.lang.Class.forName(Class.java:513)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(ServiceLoader.java:1217)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1228)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1273)
	at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1309)
	at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1393)
	at org.graalvm.polyglot/org.graalvm.polyglot.Engine.loadAndValidateProviders(Engine.java:1627)
	at org.graalvm.polyglot/org.graalvm.polyglot.Engine$1.run(Engine.java:1712)
	at org.graalvm.polyglot/org.graalvm.polyglot.Engine$1.run(Engine.java:1707)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:319)
	at org.graalvm.polyglot/org.graalvm.polyglot.Engine.initEngineImpl(Engine.java:1707)
	at org.graalvm.polyglot/org.graalvm.polyglot.Engine$ImplHolder.<clinit>(Engine.java:190)

** calling code:**

import org.graalvm.polyglot.Context;
Context context = Context.create();
String jsCode = getResourceString("JavaStream");
context.eval("js", jsCode);

** Project framework : Javafx** ** java jdk : 17** ** My MVN configuration :**

<dependency>
            <groupId>org.graalvm.sdk</groupId>
            <artifactId>graal-sdk</artifactId>
            <version>23.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.graalvm.js</groupId>
            <artifactId>js</artifactId>
            <version>23.0.3</version>
        </dependency>
        <dependency>
            <groupId>org.graalvm.js</groupId>
            <artifactId>js-scriptengine</artifactId>
            <version>23.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.graalvm.truffle</groupId>
            <artifactId>truffle-api</artifactId>
            <version>23.1.2</version>
        </dependency>

ljy1058318852 avatar Mar 17 '24 14:03 ljy1058318852

@chumer God, help me

ljy1058318852 avatar Mar 19 '24 01:03 ljy1058318852

I have the same issue.

SenkJu avatar Mar 20 '24 19:03 SenkJu

Same here!

bios64 avatar Jun 25 '24 08:06 bios64

Same here!

nicolasrvivas avatar Jul 31 '24 10:07 nicolasrvivas

I have no problem now, but I don't remember the reason. I have downgraded the version and now I am using 22.3.5 <dependency> <groupId>org.graalvm.sdk</groupId> <artifactId>graal-sdk</artifactId> <version>22.3.5</version> </dependency> <dependency> <groupId>org.graalvm.js</groupId> <artifactId>js</artifactId> <version>22.3.5</version> </dependency> <dependency> <groupId>org.graalvm.js</groupId> <artifactId>js-scriptengine</artifactId> <version>22.3.5</version> </dependency>

I still remember that I had a conflict with the regular parser and other packages at the time, and it was resolved afterwards. I don't remember if it had anything to do with this I hope it can help you

ljy1058318852 avatar Jul 31 '24 14:07 ljy1058318852

Same issue here. 🥹

jiananalvin avatar Aug 21 '24 20:08 jiananalvin

Sorry for the delay.

The problem is likely:

        <dependency>
            <groupId>org.graalvm.js</groupId>
            <artifactId>js</artifactId>
            <version>23.0.3</version>
        </dependency>
        <dependency>
            <groupId>org.graalvm.truffle</groupId>
            <artifactId>truffle-api</artifactId>
            <version>23.1.2</version>
        </dependency>

There are two incompatible versions of JS and Truffle. Please only use the same version for both. See: https://www.graalvm.org/latest/reference-manual/embed-languages/#dependency-setup

chumer avatar Oct 15 '24 09:10 chumer

I have a hard time reproducing this. My sample pom does not fail:

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>org.graalvm.test</groupId>
	<artifactId>basic-embedding</artifactId>
	<version>0.0.1-SNAPSHOT</version>


	<dependencies>
		<dependency>
			<groupId>org.graalvm.sdk</groupId>
			<artifactId>graal-sdk</artifactId>
			<version>23.1.2</version>
		</dependency>
		<dependency>
			<groupId>org.graalvm.js</groupId>
			<artifactId>js</artifactId>
			<version>23.0.3</version>
		</dependency>
		<dependency>
			<groupId>org.graalvm.js</groupId>
			<artifactId>js-scriptengine</artifactId>
			<version>23.1.2</version>
		</dependency>
		<dependency>
			<groupId>org.graalvm.truffle</groupId>
			<artifactId>truffle-api</artifactId>
			<version>23.1.2</version>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.13.2</version>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.11.0</version>
				<configuration>
					<source>17</source>
					<target>17</target>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>

There must be something wrong with the Java command line. Can someone having this issue please share their full Java command line? Thanks!

chumer avatar Oct 15 '24 10:10 chumer

Today I ran into the same issue. In my case, it only happened while deploying my app in a Docker container on Azure. When I ran the container locally, I got a bit a different error: java.nio.file.AccessDeniedException: /home/nonroot (nonroot is a user created while building the image). Finally I resolved this error by changing the cache path to a writeable location: -Dpolyglot.engine.userResourceCache=/app/cache/polyglot After that the error did not happen again on Azure.

repolevedavaj avatar Jan 12 '25 21:01 repolevedavaj

I ran into this problem with 23.1.6 of polyglot and truffle-api. I just moved to the 24.1.2 and it looks like the Engine is created and launched. Not sure if this is a red herring or indicative of where the bug is. I am running graalvm 23.0.1 on Windows 10. Haven't yet tested on linux or docker/podman.

gsteri1 avatar Jan 30 '25 17:01 gsteri1