2

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.

  • 1
    None of the Java versions you mention are meant for production - they are briefly supported versions to introduce new features. Indeed, Java 16 will not be supported in a month or so. The last production caliber release of Java was Java 11 and the next will be Java 17. If you know that JDK 14+ is not supported why bother? – stdunbar Aug 11 '21 at 22:51
  • Ok, I am still newer to the field (just graduated about a month ago) so still learning. Would you say that since the JDKs between 11 and 17 are not meant for production that they should not be used for automation testing? Since posting this question, I've reverted to JDK 11 since JDK 14 is not allowed by our IT department and our team is hesitant to update Karate at this time so we couldn't move to JDK 16. – Allison Crenshaw Aug 23 '21 at 16:04

2 Answers2

2

Please upgrade to Karate 1.0 (1.1.0 is the latest as of now) because old versions don't support newer Java versions.

Note that you may need to make a few changes: https://github.com/intuit/karate/wiki/1.0-upgrade-guide

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Thank you for this. Got word today from our test lead also that this is the issue. They are concerned that our tests may not be compatible with the latest version of Karate though so not sure how we are going to proceed. – Allison Crenshaw Aug 12 '21 at 15:04
  • @AllisonCrenshaw please tell your test lead that I spent the last 6 months making RC versions asking teams to test and provide feedback: https://twitter.com/KarateDSL/status/1417856321743822851 – Peter Thomas Aug 12 '21 at 15:10
0

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.

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
  • Yeah I noticed this note as well, but it didn't seem to just be a warning given that nothing would actually run. There was previously an warning message about how Nashorn engine wouldn't be supported in future JDKs but it never stopped tests from running. – Allison Crenshaw Aug 12 '21 at 14:05