1 year ago

#122747

test-img

Abel Durán Guerrero

"Class not found" when runing feature with karate.jar

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.

java

classpath

karate

graalvm

graaljs

0 Answers

Your Answer

Accepted video resources