Describe the bug
If in my code i try to initialize a jscontext: Context.create("js") i get this error
java.lang.IllegalAccessError: superclass access check failed: class com.oracle.truffle.polyglot.PolyglotImpl (in unnamed module @0xa18e355) cannot access class org.graalvm.polyglot.impl.AbstractPolyglotImpl (in module org.graalvm.sdk) because module org.graalvm.sdk does not export org.graalvm.polyglot.impl to unnamed module @0xa18e355
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:365)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:323)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:371)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:323)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(ServiceLoader.java:1209)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1220)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1264)
at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1299)
at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1384)
at org.graalvm.sdk/org.graalvm.polyglot.Engine$1.searchServiceLoader(Engine.java:707)
at org.graalvm.sdk/org.graalvm.polyglot.Engine$1.run(Engine.java:694)
at org.graalvm.sdk/org.graalvm.polyglot.Engine$1.run(Engine.java:668)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at org.graalvm.sdk/org.graalvm.polyglot.Engine.initEngineImpl(Engine.java:668)
at org.graalvm.sdk/org.graalvm.polyglot.Engine.access$000(Engine.java:103)
at org.graalvm.sdk/org.graalvm.polyglot.Engine$ImplHolder.<clinit>(Engine.java:112)
at org.graalvm.sdk/org.graalvm.polyglot.Engine.getImpl(Engine.java:264)
at org.graalvm.sdk/org.graalvm.polyglot.Engine$Builder.build(Engine.java:502)
at org.graalvm.sdk/org.graalvm.polyglot.Context$Builder.build(Context.java:1444)
at org.graalvm.sdk/org.graalvm.polyglot.Context.create(Context.java:709)
at io.abner.quarkus.ExampleResource.<init>(ExampleResource.kt:13)
at io.abner.quarkus.ExampleResource_Bean.create(ExampleResource_Bean.zig:127)
at io.abner.quarkus.ExampleResource_Bean.create(ExampleResource_Bean.zig:142)
at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:79)
at io.quarkus.arc.impl.ComputingCache$CacheFunction.lambda$apply$0(ComputingCache.java:99)
at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
at io.quarkus.arc.impl.ComputingCache.getValue(ComputingCache.java:41)
at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:25)
at io.abner.quarkus.ExampleResource_Bean.get(ExampleResource_Bean.zig:174)
at io.abner.quarkus.ExampleResource_Bean.get(ExampleResource_Bean.zig:190)
at io.quarkus.arc.impl.ArcContainerImpl.beanInstanceHandle(ArcContainerImpl.java:380)
at io.quarkus.arc.impl.ArcContainerImpl.beanInstanceHandle(ArcContainerImpl.java:393)
at io.quarkus.arc.impl.ArcContainerImpl$1.get(ArcContainerImpl.java:244)
at io.quarkus.arc.impl.ArcContainerImpl$1.get(ArcContainerImpl.java:241)
at io.quarkus.arc.runtime.ArcRecorder$2$1.create(ArcRecorder.java:84)
at io.quarkus.resteasy.common.runtime.QuarkusConstructorInjector.construct(QuarkusConstructorInjector.java:54)
at org.jboss.resteasy.plugins.server.resourcefactory.POJOResourceFactory.createResource(POJOResourceFactory.java:70)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:368)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:67)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:488)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:259)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:160)
at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:362)
at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:163)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:245)
at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:132)
at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.access$000(VertxRequestHandler.java:37)
at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:94)
at io.quarkus.runtime.CleanableExecutor$CleaningRunnable.run(CleanableExecutor.java:231)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
at java.base/java.lang.Thread.run(Thread.java:834)
at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Expected behavior
Expected to work just fine, as it works if i do generate a jar and runs from it.
Native image works all well. Of course, if i add quarkus.native.additional-build-args =--language:js to application.properties
Actual behavior*
It fails as described in the bug description. java.lang.IllegalAccessError: superclass access check failed ...
To Reproduce
Steps to reproduce the behavior:
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js</artifactId>
<version>19.3.1</version>
</dependency>
# Add your application.properties here, if applicable.
quarkus.native.additional-build-args =--language:js
Environment (please complete the following information):
uname -a or ver: Ubuntu 19.10java -version: openjdk version "11.0.6" 2020-01-14mvnw --version or gradlew --version): Apache Maven 3.6.3Hello abner, Is this failing in dev mode or in native mode? The reason I ask is, the quarkus.native.additional-build-args is only applicable for native image build, but your issue title suggests this is about dev mode?
Does it work if you use <scope>provided</scope> ?
hello
any possible solutions for using graal-js in dev mode?
Did you try changing the scope to provided?
yes, I tried
The results from my tests:
Hi,
I'm having the same problem trying to run a R script.
My workaround was to use:
1.quarkus.native.additional-build-args =--language:R
mvn packagejava -jar target/xxxxx-SNAPSHOT-runner.jarI couldn't make it work with quarkus dev mode.
I'm with java 11 on graalvm 20.
hello
thanks for the workaround. We also use such solution in our project. But it will be great to work with quarkusDev mode because it brings more flexibility in development.
we need to fork quarkus and edit https://github.com/quarkusio/quarkus/blob/master/core/runtime/pom.xml
there we need to add the support for that in the artifacts parent section like graal sdk
<parentFirstArtifact>org.graalvm.sdk:graal-sdk</parentFirstArtifact>
<parentFirstArtifact>org.graalvm.truffle:truffle-api</parentFirstArtifact>
<parentFirstArtifact>org.graalvm.js:js</parentFirstArtifact>
Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
ParentFirstArtifacts can be contributed by any extension, you can write your own extension that just has this if you really want. If this does fix the problem though we should just include it in Quarkus out of the box.
@stuartwdouglas it would be a big help if you could get a example working with quarkus and graaljs so that when using graalvm-ce 20.2 quarkus and graaljs do work out of the box.
I am total new to Java i just learned the internals i am coming from C, Rust, ECMAScript. I do not fully understand all parts of the class loader symantics at present but i can clear see it is a problem
and i see the relation to the issue. A person like you who is familar with java class loaders and init of them probally understands what to do.
m.oracle.truffle.polyglot.PolyglotImpl (in unnamed module @0xa18e355) cannot access class org.graalvm.polyglot.impl.AbstractPolyglotImpl (in module org.graalvm.sdk) because module org.graalvm.sdk does not export org.graalvm.polyglot.impl to unnamed module @0xa18e355
Do you have a simple example I can play around with?
@stuartwdouglas after discussion of all issues i came to the conclusion that quarkus is simply not the best fit for a project like mine as you got to many dependencys that collid with my environment.
i am running on current java and that did cause the most issues i can faster produce nativ images without quarkus i think.
i did only tryed it because i thought it could handle incremental builds for me.
It is maybe only use able if everything is a extension and i have no time to learn that framework but thanks for the help.
There is a simple reproducer application: https://github.com/alukin/polyglot-test-quarkus
like mentionned in another issue (link below) It's now working.
https://github.com/quarkusio/quarkus/issues/8035#issuecomment-733047226
with quarkus 1.9.0.Final and Graal VM 20.2.0
@frank-dspeed I think that with a good configuration, Quarkus can do the job even for a big project, and maybe better than others. Especially for building a native image
@abouhabb sure once you know that good config it is easy but the way to get such a good one is unclear and full of corner stones that i do not have when i can simply fire and adjust the build command for native image.