quarkus: regression from quarkus 1.2.1 - polyglot app fails with module org.graalvm.sdk does not export org.graalvm.polyglot.impl to unnamed

Describe the bug Project scaffolded at https://code.quarkus.io/ - depending on io.quarkus:quarkus-core:jar:1.5.2.Final, and extended with polyglot code below, fails at execution with an exception: com.oracle.truffle.polyglot.PolyglotImpl (in unnamed module) cannot access class org.graalvm.polyglot.impl.AbstractPolyglotImpl The same app, but with quarkus 1.2.1, passes the test.

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {
        String out = "From JS:";
        try (Context context = Context.create()) {
            Value function = context.eval("js", "x => x+1");
            assert function.canExecute();
            int x = function.execute(41).asInt();
            out=out+x;
            System.out.println(out);
        }
        return "hello";
    }

I’ve added the following dependencies to pom.xml in the scaffolded project to enable polyglot code:

<dependency>
  <groupId>org.graalvm.js</groupId>
  <artifactId>js</artifactId>
  <version>19.3.1</version>
</dependency>
<dependency>
  <groupId>org.graalvm.js</groupId>
  <artifactId>js-scriptengine</artifactId>
  <version>19.3.1</version>
</dependency>
<dependency>
  <groupId>org.graalvm.truffle</groupId>
  <artifactId>truffle-api</artifactId>
  <version>19.3.1</version>
</dependency>

I’ve selected GraalVM 19.3.1 to use, because I’ve noted that there is dependency on it in the clean scaffolded project:

$ mvn dependency:tree
...
[INFO] |  +- io.quarkus:quarkus-core:jar:1.5.2.Final:compile
[INFO] |  |  +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] |  |  +- jakarta.inject:jakarta.inject-api:jar:1.0:compile
[INFO] |  |  +- io.quarkus:quarkus-ide-launcher:jar:1.5.2.Final:compile
[INFO] |  |  +- io.smallrye.config:smallrye-config:jar:1.7.0:compile
[INFO] |  |  |  \- io.smallrye.config:smallrye-config-common:jar:1.7.0:compile
[INFO] |  |  +- org.jboss.logmanager:jboss-logmanager-embedded:jar:1.0.4:compile
[INFO] |  |  +- org.jboss.logging:jboss-logging-annotations:jar:2.1.0.Final:compile
[INFO] |  |  +- org.jboss.threads:jboss-threads:jar:3.1.1.Final:compile
[INFO] |  |  +- org.slf4j:slf4j-api:jar:1.7.30:compile
[INFO] |  |  +- org.jboss.slf4j:slf4j-jboss-logging:jar:1.2.0.Final:compile
[INFO] |  |  +- org.graalvm.sdk:graal-sdk:jar:19.3.1:compile
[INFO] |  |  +- org.wildfly.common:wildfly-common:jar:1.5.4.Final-format-001:compile

Expected behavior Test is passing, i.e. JS code is executed by GraalVM and response is returned.

Actual behavior Test is failing with exception.

To Reproduce

git clone https://github.com/miloslavskacel/polyglotcode-with-quarkus.git
cd polyglotcode-with-quarkus
mvn clean package

Test is failing.

Environment (please complete the following information):

$ uname -a
MINGW64_NT-10.0-18363 SKMW 3.0.7-338.x86_64 2019-07-03 15:16 UTC x86_64 Msys

$ java -version
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment GraalVM CE 19.3.1 (build 11.0.6+9-jvmci-19.3-b07)
OpenJDK 64-Bit Server VM GraalVM CE 19.3.1 (build 11.0.6+9-jvmci-19.3-b07, mixed mode, sharing)

$ ./mvnw --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\Users\uzimskacel\.m2\wrapper\dists\apache-maven-3.6.3-bin\1iopthnavndlasol9gbrbg6bf2\apache-maven-3.6.3
Java version: 11.0.6, vendor: Oracle Corporation, runtime: C:\java\graalvm-ce-java11-19.3.1
Default locale: en_US, platform encoding: Cp1250
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
  • Quarkus version or git rev: io.quarkus:quarkus-core:jar:1.5.2.Final

Additional context Reported also on:

Full stacktrace

2020-06-24 16:42:24,579 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-1) HTTP Request to /hello failed, error id: d698b4a3-8894-46f7-b73d-f9e48d8a348e-1: org.jboss.resteasy.spi.UnhandledException: java.lang.IllegalAccessError: superclass access check failed: class com.oracle.truffle.polyglot.PolyglotImpl (in unnamed module @0x34575a82) 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 @0x34575a82
        at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
        at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372)
        at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:216)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:515)
        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 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)
Caused by: java.lang.IllegalAccessError: superclass access check failed: class com.oracle.truffle.polyglot.PolyglotImpl (in unnamed module @0x34575a82) 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 @0x34575a82
        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:372)
        at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:330)
        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 tst.graal.ExampleResource.hello(ExampleResource.java:18)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
        at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:621)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:487)
        at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:437)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:362)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:439)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:400)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:374)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:67)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:488)
        ... 17 more

Regression from quarkus 1.2.1

Test is passing for quarkus 1.2.1, which is the last release passing the test. Older releases are failing. Below is a change in pom.xml needed to make app at https://github.com/miloslavskacel/polyglotcode-with-quarkus.git passing tests.

image

Full pom.xml with quarkus 1.2.1

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>tst.graal</groupId>
  <artifactId>polyglotcode-with-quarkus</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <properties>
    <compiler-plugin.version>3.8.1</compiler-plugin.version>
    <maven.compiler.parameters>true</maven.compiler.parameters>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <quarkus-plugin.version>1.2.1.Final</quarkus-plugin.version>
    <quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
    <quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
    <quarkus.platform.version>1.2.1.Final</quarkus.platform.version>
    <surefire-plugin.version>2.22.1</surefire-plugin.version>
  </properties>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>${quarkus.platform.group-id}</groupId>
        <artifactId>${quarkus.platform.artifact-id}</artifactId>
        <version>${quarkus.platform.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-resteasy</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-junit5</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.rest-assured</groupId>
      <artifactId>rest-assured</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.graalvm.js</groupId>
      <artifactId>js</artifactId>
      <version>19.3.1</version>
    </dependency>
    <dependency>
      <groupId>org.graalvm.js</groupId>
      <artifactId>js-scriptengine</artifactId>
      <version>19.3.1</version>
    </dependency>
    <dependency>
      <groupId>org.graalvm.truffle</groupId>
      <artifactId>truffle-api</artifactId>
      <version>19.3.1</version>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-maven-plugin</artifactId>
        <version>${quarkus-plugin.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>build</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${compiler-plugin.version}</version>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${surefire-plugin.version}</version>
        <configuration>
          <systemPropertyVariables>
            <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
          </systemPropertyVariables>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>native</id>
      <activation>
        <property>
          <name>native</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${surefire-plugin.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
                <configuration>
                  <systemPropertyVariables>
                    <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
                  </systemPropertyVariables>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      <properties>
        <quarkus.package.type>native</quarkus.package.type>
      </properties>
    </profile>
  </profiles>
</project>

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 21 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Always better to try things before we merge them 😃.

There is some advice here on how to do it: https://github.com/quarkusio/quarkus/blob/main/CONTRIBUTING.md#building-main - except you have to build @geoand 's branch, not main.

Any chance you could try #26171 ?

Sure. Will try once its merged @geoand ?

@roudra i solved it via building quarkus projects as uber jar and then use that in a example application like this https://www.graalvm.org/22.1/reference-manual/embed-languages/#build-native-images-from-polyglot-applications

polyglot with other languages i my self was not able to understand whats wrong with quarkus or how quarkus works. but the low level graalvm builds it self to work always without problems.

same for me, uber jar helped

@roudra i solved it via building quarkus projects as uber jar and then use that in a example application like this https://www.graalvm.org/22.1/reference-manual/embed-languages/#build-native-images-from-polyglot-applications

polyglot with other languages i my self was not able to understand whats wrong with quarkus or how quarkus works. but the low level graalvm builds it self to work always without problems.