JDK version updated, now Karate tests cannot be found

Viewed 1609

Today our IT department initialized an automatic uninstall of Java JDK 14 due to some security concern. I downloaded the latest, JDK 16, and updated all of my project settings using this as a guide: Error:java: invalid source release: 8 in Intellij. What does it mean?

I also updated the JAVA_HOME environment variable and the path variable. However, when attempting to run my Karate automation tests using IntelliJ like I normally do, I am getting an error that no tests were found. Here is the full system response when trying to run a test:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.intuit.karate.Runner$Builder.tagSelector(Runner.java:80)
    at com.intuit.karate.Runner.parallel(Runner.java:309)
    at com.intuit.karate.Runner$Builder.parallel(Runner.java:190)
    at com.intuit.karate.cli.Main.main(Main.java:59)
    at cucumber.api.cli.Main.main(Main.java:34)
Caused by: java.lang.NullPointerException: Cannot invoke "javax.script.ScriptEngine.createBindings()" because "com.intuit.karate.ScriptBindings.NASHORN" is null
    at com.intuit.karate.ScriptBindings.createBindings(ScriptBindings.java:160)
    at com.intuit.karate.core.Tags.<init>(Tags.java:158)
    at com.intuit.karate.core.Tags.<clinit>(Tags.java:48)
    ... 5 more

Process finished with exit code 1

Apparently this is a problem with JDK versions above 14. I tried to troubleshoot with this video: https://www.youtube.com/watch?v=8bHeDl3tdoo

But after making that change to the pom.xml file, now I'm getting a new error:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/allison_crenshaw/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/allison_crenshaw/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.14.0/log4j-slf4j-impl-2.14.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

I visited the page it recommends (http://www.slf4j.org/codes.html#multiple_bindings) but I don't really understand how to proceed after reading the explanation. I tried adding in the exclusion it recommends but my pom.xml file is really long so I wasn't really sure where the exclusion code belonged in the grand scheme of things. I tried putting it just under the code recommended by the YouTube video to resolve the binding issue but I got the same error about the class path containing multiple SLF4J bindings.

Thanks in advance for any help.

2 Answers

This SLF4J message is not an error but just a warning:

SLF4J API is designed to bind with one and only one underlying logging framework at a time. If more than one binding is present on the class path, SLF4J will emit a warning, listing the location of those bindings.

[...]

NOTE The warning emitted by SLF4J is just that, a warning. Even when multiple bindings are present, SLF4J will pick one logging framework/implementation and bind with it.

[Emphasis by me.]

If the logging framework that has been selected is fine for you, you don't have to worry. If you want to get rid of the message you can check with mvn dependency:tree on your project which dependency pulls in which logging framework and set <exclusions> in your POM for those you don't want.

Related