karate: `Java.type()` fails with a PolyglotException when attempting to launch a Karate server
I’m running into the following error when I attempt launch a server using a feature file with Java interop:
org.graalvm.polyglot.PolyglotException: TypeError: Access to host class JWTUtil is not allowed or does not exist.
I’ve never run into this before, but this is the first Gradle project I’ve worked on (all others I support are Maven), so perhaps that’s the culprit?
Apologies if this is a silly oversight on my part. I’ve tried a number of things to work around this – moving things to the src/main folder; moving things to the /resources sub folder; using the ZIP release JAR instead of the regular karate.jar – all to no avail.
Sample project is attached – wouldn’t be surprised at all if launching the server works for you, and this is an IntelliJ setting issue, so again, apologies in advance if that’s the case!
Complete error details:
ERROR com.intuit.karate - mock-server background failed - test-server.feature:4
com.intuit.karate.KarateException: mock-server background failed - test-server.feature:4
at com.intuit.karate.core.MockHandler.<init>(MockHandler.java:111)
at com.intuit.karate.core.MockServer$Builder.build(MockServer.java:129)
at com.intuit.karate.Main.call(Main.java:396)
at com.intuit.karate.Main.call(Main.java:58)
at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
at picocli.CommandLine.access$1300(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
at picocli.CommandLine.execute(CommandLine.java:2078)
at com.intuit.karate.Main.main(Main.java:298)
Caused by: com.intuit.karate.KarateException: js failed:
>>>>
01: Java.type('JWTUtil')
<<<<
org.graalvm.polyglot.PolyglotException: TypeError: Access to host class JWTUtil is not allowed or does not exist.
- <js>.:program(Unnamed:1)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (9 by maintainers)
Commits related to this issue
- improve mocks cli #1967 — committed to karatelabs/karate by ptrthomas 2 years ago
No need! I was just testing this out now and it works just fine. The stackoverflow link was very helpful, as well. Thanks again!