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

graal-js does not work when using quarkusDev #9634

Closed
abner opened this issue May 27, 2020 · 16 comments
Closed

graal-js does not work when using quarkusDev #9634

abner opened this issue May 27, 2020 · 16 comments
Labels
kind/bug Something isn't working
Milestone

Comments

@abner
Copy link

abner commented May 27, 2020

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:

  1. Create a project using https://code.quarkus.io/
  2. Add dependencies to graal-js
<dependency>
      <groupId>org.graalvm.js</groupId>
      <artifactId>js</artifactId>
      <version>19.3.1</version>
</dependency>
  1. Configuration
# Add your application.properties here, if applicable.
quarkus.native.additional-build-args =--language:js

Environment (please complete the following information):

  • Output of uname -a or ver: Ubuntu 19.10
  • Output of java -version: openjdk version "11.0.6" 2020-01-14
  • GraalVM version (if different from Java): OpenJDK Runtime Environment GraalVM CE 19.3.1 (build 11.0.6+9-jvmci-19.3-b07)
  • Quarkus version or git rev: 1.4.2.Final and 1.5.0.CR1
  • Build tool (ie. output of mvnw --version or gradlew --version): Apache Maven 3.6.3
@abner abner added the kind/bug Something isn't working label May 27, 2020
@jaikiran
Copy link
Member

Hello 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?

@stuartwdouglas
Copy link
Member

stuartwdouglas commented Jun 1, 2020

Does it work if you use <scope>provided</scope> ?

@antonliauchuk-tealium
Copy link

hello

any possible solutions for using graal-js in dev mode?

@stuartwdouglas
Copy link
Member

Did you try changing the scope to provided?

@antonliauchuk-tealium
Copy link

antonliauchuk-tealium commented Jun 3, 2020

yes, I tried

The results from my tests:

  1. the issue is reproduced with gradle;
  2. the issue is reproduced with versions 20.0.0 and 20.1.0 of 'org.graalvm.js:js';
  3. in the case of maven, after adding scope 'provided' to maven dependency, the behavior wasn't changed.

@cmasantos
Copy link

cmasantos commented Jun 20, 2020

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
2. mvn package
3. java -jar target/xxxxx-SNAPSHOT-runner.jar

I couldn't make it work with quarkus dev mode.
I'm with java 11 on graalvm 20.

@antonliauchuk-tealium
Copy link

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.

@frank-dspeed
Copy link

frank-dspeed commented Sep 24, 2020

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>

method 2

Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());

Related upstream issues

@stuartwdouglas
Copy link
Member

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.

@frank-dspeed
Copy link

frank-dspeed commented Sep 29, 2020

@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

@stuartwdouglas
Copy link
Member

Do you have a simple example I can play around with?

@frank-dspeed
Copy link

@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.

@oleksiylukin
Copy link

There is a simple reproducer application: https://github.com/alukin/polyglot-test-quarkus

@abouhabb
Copy link

abouhabb commented Nov 24, 2020

like mentionned in another issue (link below) It's now working.

#8035 (comment)

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

@frank-dspeed
Copy link

@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.

@stuartwdouglas
Copy link
Member

This is fixed upstream, it should work in 1.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants