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

Class Not Found org/graalvm/polyglot/Value 1.4.1 #41306

Open
abdallah-rashwan opened this issue Jun 19, 2024 · 10 comments
Open

Class Not Found org/graalvm/polyglot/Value 1.4.1 #41306

abdallah-rashwan opened this issue Jun 19, 2024 · 10 comments
Labels
kind/bug Something isn't working

Comments

@abdallah-rashwan
Copy link

Describe the bug

Using Karate for int testing, getting the below error when trying to run tests using <dependency> <groupId>com.intuit.karate</groupId> <artifactId>karate-junit5</artifactId> <scope>test</scope> </dependency>. The Value class is missing.

java.lang.NoClassDefFoundError: org/graalvm/polyglot/Value at com.intuit.karate.core.Variable.<init>(Variable.java:72) at com.intuit.karate.core.Variable.<clinit>(Variable.java:66) at com.intuit.karate.core.Config.<init>(Config.java:94) at com.intuit.karate.core.ScenarioCall.getParentConfig(ScenarioCall.java:67) at com.intuit.karate.core.ScenarioRuntime.<init>(ScenarioRuntime.java:74) at com.intuit.karate.core.ScenarioIterator.tryAdvance(ScenarioIterator.java:162) at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.lambda$initPartialTraversalState$0(StreamSpliterators.java:292) at java.base/java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.fillBuffer(StreamSpliterators.java:206) at java.base/java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.doAdvance(StreamSpliterators.java:161) at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.tryAdvance(StreamSpliterators.java:298) at java.base/java.util.Spliterators$1Adapter.hasNext(Spliterators.java:681) at com.intuit.karate.junit5.FeatureNode.hasNext(FeatureNode.java:63) at com.intuit.karate.junit5.Karate.iterator(Karate.java:65) at java.base/java.lang.Iterable.spliterator(Iterable.java:101) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

I managed to overcome this by adding graal-sdk 22.3.3 manually to be compatible with Truffle.

found this
<dependency> <groupId>org.graalvm.sdk</groupId> <artifactId>graal-sdk</artifactId> <version>23.1.2</version> <exclusions> <exclusion> <groupId>org.graalvm.polyglot</groupId> <artifactId>polyglot</artifactId> </exclusion> </exclusions> </dependency> in "quarkus-bom-3.10.2.pom", might be useful.

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

  1. Quarkus version 3.10.2
  2. com.intuit.karate karate-junit5-1.4.1

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@abdallah-rashwan abdallah-rashwan added the kind/bug Something isn't working label Jun 19, 2024
@jamailun
Copy link

Same issue here, with Quarkus 3.11.2.

@gsmet
Copy link
Member

gsmet commented Jun 21, 2024

A small Maven reproducer might help.

@jamailun
Copy link

How to reproduce

Ok, so that's what I found.I don't expect any real answer : I'm just writting my search :)
Here's the project holding a small demo: https://github.com/jamailun/karate-quarkus.
It will work on Quarkus 3.8.2 : the demo feature will run properly.

Step 1: upgrade Quarkus to 3.8.3+

From the version 3.8.3 (and commit #39442) sdk-graal has been excluded.
So when launching the test, we obtain a :
java.lang.NoClassDefFoundError: org/graalvm/polyglot/Value

Step 2 : Add sdk-graal (you can skip this one)

By adding the graal-sdk (and decommenting the block on line 69 of my demo), you'll have a new exception:
ServiceConfiguration org.graalvm.polyglot.impl.AbstractPolyglotImpl: com.oracle.truffle.polyglot.PolyglotImpl not a subtype.
Same for previous versions.

Step 3 : Add a only the most recent Graal's polyglot dependency

I discovered that from 23.1.0 onward, developpers should import Graal SDK differently.
By recommenting the previous block and importing only the org.graalvm.polyglot.polyglot:24.0.1 (decomment block line 77 on my pom.xml) now everything will compile... but the tests won't be found. Even with debug mode, Karate just doesn't find the .feature anymore.
FooUnitTests.testAllUnitTests no features or scenarios found: [classpath:org/jamailun]

Need help

And now I don't really know where to look. We'd like to keep our karate tests (we do have a lot of them) so any help would be gladly received.

@jamailun
Copy link

Bump ?

@francoisvandenplas
Copy link

Hello,
same issue here, with Quarkus 3.13.2.

@jamailun
Copy link

Bump again.

@Lmbwilly
Copy link

@jamailun You should use the new version of karate-junit5, they changed the group-id to io.karatelabs, see the new version: Release note of Karate-JUnit5 1.5.0

@jamailun
Copy link

@Lmbwilly I've checked it with latest release of Quarkus. Now, we don't have errors but Karate cannot find any tests.

I've updated my reproducer.

Just to insist : the tests do work well with Quarkus 3.8.2 and Karate 1.4.1.

@Lmbwilly
Copy link

@jamailun I've checked your reproducer and I only changed the call of the runner to return Karate.run("classpath:org/jamailun/00.hello-world.feature"); and then it worked.
And I know with 3.8.2 all worked fine, I had the same problem as you.

@jamailun
Copy link

jamailun commented Oct 3, 2024

Polyglot

@Lmbwilly You did ? Didn't you also add to add the -Dpolyglotimpl.DisableVersionChecks=true argument ? I don't know why, but with this setup, the dependency:tree shows :

...
[INFO] \- io.karatelabs:karate-junit5:jar:1.5.0:test
[INFO]    +- io.karatelabs:karate-core:jar:1.5.0:test
[INFO]    |  +- org.graalvm.js:js-scriptengine:jar:24.0.0:test
[INFO]    |  |  \- org.graalvm.polyglot:polyglot:jar:24.0.0:test
[INFO]    |  |     \- org.graalvm.sdk:collections:jar:24.0.0:test
[INFO]    |  +- org.graalvm.js:js-language:jar:23.1.2:test
[INFO]    |  |  +- org.graalvm.regex:regex:jar:23.1.2:test
[INFO]    |  |  +- org.graalvm.truffle:truffle-api:jar:23.1.2:test
[INFO]    |  |  \- org.graalvm.shadowed:icu4j:jar:23.1.2:test
...

So Truffle and Polyglot do not have the same verion in karate 1.5.0 🤔 It's not that bad, but I still find it sad to be obligated of using a specific environment variable. And without it, Truffle will refuse to execute the Karate test.

Replacement of #relativeTo()

For anyone looking for a way to make the Karate#relativeTo(Class<?>) work again, this is an equivalent I've made using Reflections 0.9.9-RC1 :

// Put this somewhere
public static String[] allFeaturesRelativeTo(Class<?> clazz) {
    Reflections reflections = new Reflections(clazz.getPackageName(), new ResourcesScanner());
    return reflections.getResources(Pattern.compile(".*\\.feature")).stream()
        .map(r -> "classpath:" + r)
        .toArray(String[]::new);
}

// So the test method can be :
@Karate.Test
Karate testAllUnitTests() {
      return Karate.run(allFeaturesRelativeTo(getClass()))
          .tags("@foo");
}

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

5 participants