Closed cnrani closed 7 years ago
Rani - I have a feeling TEP may be relying on OpenJDK, I am not 100% sure, but maybe Karate needs the Oracle JDK to work properly. Can you confirm the exact JDK version, but I will also investigate.
adding some context. Karate's CI has been running regularly on Ubuntu / Linux with this Travis setup: https://github.com/intuit/karate/blob/master/.travis.yml
closing as duplicate of #196
@ptrthomas I got same error on TEP job.
Java version: /usr/java/default/bin/java java version "1.8.0_144" Java(TM) SE Runtime Environment (build 1.8.0_144-b01) Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
Stacktrace:
Caused by: java.lang.ClassNotFoundException: jdk.nashorn.api.scripting.ScriptObjectMirror
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.maven.surefire.booter.IsolatedClassLoader.loadClass(IsolatedClassLoader.java:97)
at com.intuit.karate.ScriptValue.
@amitnagesh refer #196 this is because only the JRE is installed. please work with the folks who own the build node and fix, this is not an issue with karate, thanks.
This problem can be resolved by updating Maven to 3.6.0 as well if you can. However, if using openjdk, another problem will arise with an error stating "cannot load FreeBooter" or something like that. Fixing this by adding the maven-surefire-plugin configuration <useSystemClassLoader>false</useSystemClassLoader>
fixes the above problem, but creates the problem reported in this issue.
To fix both problems, update Maven to 3.6.0 and also update Maven Surefire Plugin to 3.0.0-M1. Updating Maven will fix the problem alone if you are using Oracle JDK, but not for OpenSDK.
To fix the problem while using openjdk, change your Maven Surefire Plugin to the following:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M1</version>
...
</plugin>
thanks @vnayar !
I encountered this as a result of having the following surefire plugin configuration:
<configuration>
<forkCount>0</forkCount>
</configuration>
My guess as to whats happening: The software you're running requires a jdk, however maven runs with the jre. If you don't fork then you'll be using maven's JRE, instead of forking into a new JDK.
@rrowlands thanks ! that makes sense and explains some of the observations. I'll point others to this when needed. also provides some ideas on better detection of this case in the future, at least for more helpful logs
Hi Peter,
We have written webservice tests in karate and able to run the tests on local mac machine but currently getting the error java.lang.NoClassDefFoundError: jdk/nashorn/api/scripting/ScriptObjectMirror while running on Linux box. Initially we were getting nullpointer exception and sent a PR and after the merge, we started getting another issue "java.lang.NoClassDefFoundError: jdk/nashorn/api/scripting/NashornScriptEngineFactory". We sent the PR for to fix this and now we are getting another issue "java.lang.NoClassDefFoundError: jdk/nashorn/api/scripting/ScriptObjectMirror". The Java version on my mac and TEP(linux) is same and the only difference is operating system. Do you have any fix for this.
Thanks, Rani