`Java.type()` fails with a PolyglotException when attempting to launch a Karate server
See original GitHub issueI’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)
Issue Analytics
- State:
- Created a year ago
- Comments:15 (9 by maintainers)
Top Results From Across the Web
Getting PolyglotException in karate API framework even ...
Try using the full path like. * def requestBody = read('classpath:src/test/java/requests/first.json'). Share. Share a link to this answer.
Read more >Karate | Test Automation Made Simple.
Karate is the only open-source tool to combine API test-automation, mocks, performance-testing and even UI automation into a single, unified framework.
Read more >7 New Features in Karate Test Automation Version 1.0
Version 1.0 of the Karate Test Automation Framework is within reach. I checked out the new features, and here are my 7 key...
Read more >PolyglotException (GraalVM SDK Java API Reference)
A polyglot exception represents errors that contain Graal guest languages on the stack trace. In addition to the Java stack trace it also...
Read more >intuit - Bountysource
Karate -gatling today provides a way to run performance tests by ... Java type in karate-config with parallel runner causing error: Multi threaded...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No need! I was just testing this out now and it works just fine. The stackoverflow link was very helpful, as well. Thanks again!
can reopen if needed