How to fix problem with NoClassDefFoundError - kotlin

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

Related

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.

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

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.

deferredCurrentActivation fatal exception

I'm suddenly seeing the following on Crashlytics for a macOS app, and this seems to happen only on macOS 10.14. I have no idea what this is. What's deferredCurrentActivation and how do I avoid this? Anyone else seen this?
Fatal Exception: NSInternalInconsistencyException
deferredCurrentActivation already set when we got another deferred activate event

IntelliJ: Kotlin error causes mouse flicker and errors in code

I'm using IntelliJ 15 with Kotlin beta-1038, and I'm getting this error at the bottom of eclipse.
Internal Error occurred while analyzing this expression:
java.util.ServiceConfigurationError: org.jetbrains.kotlin.resolve.ExternalOverridabilityCondition: Provider org.jetbrains.kotlin.load.java.ErasedOverridabilityCondition not found
at java.util.ServiceLoader.fail(ServiceLoader.java:239)
at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:372)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
at kotlin.CollectionsKt___CollectionsKt.toCollection(_Collections.kt:949)
at kotlin.CollectionsKt.toCollection(Unknown Source)
at kotlin.CollectionsKt___CollectionsKt.toArrayList(_Collections.kt:942)
at kotlin.CollectionsKt.toArrayList(Unknown Source)
at kotlin.CollectionsKt___CollectionsKt.toList(_Collections.kt:973)
at kotlin.CollectionsKt.toList(Unknown Source)
at org.jetbrains.kotlin.resolve.OverridingUtil.<clinit>(OverridingUtil.java:41)
at org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor$DeserializedClassMemberScope.generateFakeOverrides(DeserializedClassDescriptor.kt:216)
at org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor$DeserializedClassMemberScope.computeNonDeclaredFunctions(DeserializedClassDescriptor.kt:202)
at org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedMemberScope.computeFunctions(DeserializedMemberScope.kt:77)
at org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedMemberScope.access$computeFunctions(DeserializedMemberScope.kt:32)
at org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedMemberScope$functions$1.invoke(DeserializedMemberScope.kt:50)
at org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedMemberScope$functions$1.invoke(DeserializedMemberScope.kt:32)
at org.jetbrains.kotlin.storage.LockBasedStorageManager$MapBasedMemoizedFunction.invoke(LockBasedStorageManager.java:389)
at org.j...
Every Kotlin file I touch becomes full of errors and my mouse will flicker and I'll lag when I hover over any of the code. I also don't have intellisense.
However, I can compile and run the project and my changes in the kotlin files will work.
IntelliJ IDEA 15.0.4 bundles Kotlin 1.0 release. You broke your Kotlin installation because you followed the incorrect advice given to you at How to downgrade Kotlin in Intellij 15. To fix your installation, you need to reinstall IntelliJ IDEA from the original installer.

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.