1

I have a feature that execute a function from a Java class. So for this reason I use this command to get the class and create a new instance:

enter image description here

When I run this feature with maven (mvn test -Dtest...) everything is okay. The problem is when I run this feature with karate standalone jar, karate can't find the RCNUtils class.

Error:

org.graalvm.polyglot.PolyglotException: TypeError: Access to host class utilities.RCNUtils is not allowed or does not exist.

enter image description here

GraalJS error: https://github.com/oracle/graaljs/blob/master/docs/user/FAQ.md#typeerror-access-to-host-class-commyexamplemyclass-is-not-allowed-or-does-not-exist


I think it's a classpath problem but I have tried with a lot of differents paths and commands to execute the jar, and nothing works.

I don't know if this is a known issue or if there is a karate example using utilities classes and executed with karate.jar

I tested this problem with differents Karate versions. Actually I'm using Karate 1.1.0

Some of the options I have tried with no results:

  1. Use -w / --workdir param to change working directory with no results
  2. Use java -cp instead of java -jar to set classpath following: Unable to use read('classpath:') when running tests with standalone karate.jar
  3. Use -Dkarate.config.dir param

Note: I don't think it's a security problem because if I try to get "RCNUtils.java" file with "karate.read()" or "read()" in the same feature, it works. I think because I can put the path to the file. The problem is that I can't put the path to java class in "Java.type()" method

Same error here: Executing Karate jar with mock using external library Spring Framework

Thanks in advance.

  • 1
    I have nothing to suggest except that you follow this process. maybe it is a security thing, I don't know: https://github.com/karatelabs/karate/wiki/How-to-Submit-an-Issue – Peter Thomas Feb 01 '22 at 14:37
  • 1
    I was able to replicate this in a Gradle project -- will open an issue and add a zipped-up sample project. Probably an easy fix, but I'm lousy at troubleshooting this stuff. – Staffier Apr 04 '22 at 20:04

0 Answers0