Karate 0.9.1 - Exception in thread "main" java.lang.StackOverflowError - karate

When I'm trying to run *.feature file or a single scenario with "right-click" (IntelliJ Idea), I've always received an exception:
Exception in thread "main" java.lang.StackOverflowError
at java.util.HashMap.<init>(HashMap.java:457)
at java.util.LinkedHashMap.<init>(LinkedHashMap.java:347)
at java.util.HashSet.<init>(HashSet.java:162)
at java.util.LinkedHashSet.<init>(LinkedHashSet.java:154)
at jdk.nashorn.internal.runtime.ScriptObject$KeyIterator.init(ScriptObject.java:2467)
at jdk.nashorn.internal.runtime.ScriptObject$ScriptObjectIterator.hasNext(ScriptObject.java:2441)
at jdk.nashorn.api.scripting.ScriptObjectMirror$13.call(ScriptObjectMirror.java:368)
at jdk.nashorn.api.scripting.ScriptObjectMirror$13.call(ScriptObjectMirror.java:363)
at jdk.nashorn.api.scripting.ScriptObjectMirror.inGlobal(ScriptObjectMirror.java:858)
at jdk.nashorn.api.scripting.ScriptObjectMirror.entrySet(ScriptObjectMirror.java:363)
at net.minidev.json.reader.JsonWriter$7.writeJSONString(JsonWriter.java:135)
at net.minidev.json.reader.JsonWriter$7.writeJSONString(JsonWriter.java:128)
at com.intuit.karate.JsonUtils$NashornObjectJsonWriter.writeJSONString(JsonUtils.java:77)
at com.intuit.karate.JsonUtils$NashornObjectJsonWriter.writeJSONString(JsonUtils.java:67)
...
Same scenario works fine if I run with TestRunner.java. Looks like that problem is in IJ cucumber plugin.
Maybe someone has a solution or workaround for this issue.
I'm using karate 0.9.1, cucumber for Java plugin: v183.4284.148, Idea 2018.3.3

No one has reported this - and from the stack-trace it looks like some JSON that you are using is being printed to the console - has some circular references, maybe you are using a Map of object references. But yes I can't explain why this works fine in the runner.
Can you follow the instructions here and submit a sample project, we can try open it in IntelliJ: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue
EDIT: this was a cyclic reference, but we have fixed it to be safe in future.

Related

How to fix problem with NoClassDefFoundError

During work on my kotlin project using InteliJ IDE suddenly I get following error
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
at com.beust.klaxon.DefaultConverter.(DefaultConverter.kt)
My old code which compile without problems now throw this exception. How to fix it?
I don't know what is the reason - but this helps: reload gradle by click on
After that error disappear. I hope someone give explanation in separate answer

NoClassDefFoundError caused by Kotlin readLine function

Whenever i try to execute a .jar file containing my code, it throws NoClassDefFoundError: kotlin/io/ConsoleKt. So far i haven't found a solution to this problem but I think the problem has something to do with the readLine() function I have in the script but I don't know what. The weird thing is that my code ran perfectly in Intellij itself but once I built it started throwing this exception that never happened outside of IntelliJ. The specific error is:
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/io/ConsoleKt
at com.quantumzizo.calcualtorkotlin.DisplayKt.main(Display.kt:23)
at com.quantumzizo.calcualtorkotlin.DisplayKt.main(Display.kt)
Caused by: java.lang.ClassNotFoundException: kotlin.io.ConsoleKt
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 2 more
Is there solution that can solve this?
So it turns out all I had to do was build a fat jar with all the dependencies. I used the Gradle plugin Shadow to make a fat jar.
Props to #Endzeit for suggesting that I use it.

Exception while running Seedstack Application

I have used seedstack dependecies for Hibernate and JPA to create DAO services that performs crud operations on Database.
I am trying to Launch this Seedstack application module through Java application Launcher in eclipse, by SeedMain class.
In pom.xml - dependecy for undertow is given.
<dependency>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed-web-undertow</artifactId>
</dependency>
When executing the SeedMain class, I am getting the below error snakeyaml error:-
Exception in thread "main" java.lang.NoSuchMethodError: org.yaml.snakeyaml.DumperOptions.setSplitLines(Z)V
at com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.buildDumperOptions(YAMLGenerator.java:259)
at com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.<init>(YAMLGenerator.java:232)
at com.fasterxml.jackson.dataformat.yaml.YAMLFactory._createGenerator(YAMLFactory.java:447)
at com.fasterxml.jackson.dataformat.yaml.YAMLFactory.createGenerator(YAMLFactory.java:397)
at org.seedstack.seed.core.internal.diagnostic.DefaultDiagnosticReporter.writeDiagnosticReport(DefaultDiagnosticReporter.java:75)
at org.seedstack.seed.core.internal.diagnostic.DefaultDiagnosticReporter.writeDiagnosticReport(DefaultDiagnosticReporter.java:67)
at org.seedstack.seed.core.internal.diagnostic.DiagnosticManagerImpl.dumpDiagnosticReport(DiagnosticManagerImpl.java:70)
at org.seedstack.seed.core.SeedMain.handleException(SeedMain.java:68)
at org.seedstack.seed.core.SeedMain.main(SeedMain.java:61)
As per my understanding the Error is due to some version inconsistency for snakeyaml, But for Seedstack as the versions for dependecies are resolved by seedstack-bom dependecy, so where exactly should I do the changes to resolve the error.
Thanks in Advance!
From reading the stacktrace, it seems that you have some error on startup which is handled by the handleException() method. This method then tries to write a YAML diagnostic report but ultimately fails due to the snakeyaml version issue you mentioned.
You should do two things:
Fix the snakeyaml dependency issue by looking into the dependency tree. This kind of problem is often caused by some library that makes Maven choose an older version. SeedStack needs at least jackson-dataformat-yaml version 2.9.4 which in turn needs at least snakeyaml 1.18.
Fix the other error by looking at the full stacktrace. When a diagnostic report cannot be written, the original exception is still printed on the console (on stderr).

PlayORM Example compilation error

Samples run fine on my Windows 7.
However I get the following error on my Ubuntu machine:
Exception in thread "main" java.lang.NoSuchMethodError: org.joda.time.LocalDateTime.toDate()Ljava/util/Date;
at com.alvazan.orm.api.base.spi.UniqueKeyGenerator.generateKey(UniqueKeyGenerator.java:47)
at com.alvazan.orm.api.base.spi.UniqueKeyGenerator.generateNewKey(UniqueKeyGenerator.java:42)
at com.alvazan.orm.api.base.spi.UniqueKeyGenerator.generateNewKey(UniqueKeyGenerator.java:21)
at com.alvazan.orm.impl.meta.data.MetaIdField.fillInAndFetchId(MetaIdField.java:106)
at com.alvazan.orm.impl.meta.data.MetaIdField.translateToColumn(MetaIdField.java:56)
at com.alvazan.orm.impl.meta.data.MetaClassSingle.translateToRow(MetaClassSingle.java:82)
at com.alvazan.orm.layer0.base.BaseEntityManagerImpl.putImpl(BaseEntityManagerImpl.java:117)
at com.alvazan.orm.layer0.base.BaseEntityManagerImpl.put(BaseEntityManagerImpl.java:100)
at com.example.PlayORMExample.createTestData(PlayORMExample.java:89)
at com.example.PlayORMExample.main(PlayORMExample.java:31)
I looked at similar questions on the "stack", but they do not seem to apply to my case.
you either
have the wrong version of the joda-time jar OR
have two joda time jars one of which is the wrong version
later,
Dean (I am a committer on PlayOrm).

NullPointerException org.gradle.wrapper.BootstrapMainStarter.findLauncherJar(BootstrapMainStarter.java:37)

Got the following stacktrace when launching gradle 1.1, anyone know how to resolve them:
Exception in thread "main" java.lang.NullPointerException
at org.gradle.wrapper.BootstrapMainStarter.findLauncherJar(BootstrapMainStarter.java:37)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:28)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:47)
I think the automatic unzip of the dists/gradle-1.1-bin/13d7lnhcrghv2i5e54el41jpgr/gradle-1.1-bin.zip might be failing. I checked permissions and that I have access to that directory.
If I unzip manually, then I get the following error:
Exception in thread "main" java.lang.RuntimeException: Gradle distribution 'http://services.gradle.org/distributions/gradle-1.1-bin.zip' contains too many directories. Expected to find exactly 1 directory.
at org.gradle.wrapper.Install.createDist(Install.java:73)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:47)
I did a google search for gradle nullpointerexception and it mentioned the JAVA_HOME needs to be set for compiling, but I've already checked it is set correctly and been able to compile stuff with ant in that environment.
I was getting exactly same error and I changed the version of gradle that I was using. Inside my gradle-wrapper.properties, changed version 2.4 to 2.2.1 and error is gone.