question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.NoClassDefFoundError: kotlin/KotlinNothingValueException

See original GitHub issue

Hi,

I am trying to use Lingua inside a plain Java maven project and using following maven dependency for that:

<dependency>
                <groupId>com.github.pemistahl</groupId>
                <artifactId>lingua</artifactId>
                <version>1.0.3</version>
</dependency>

Code Sample:

import com.github.pemistahl.lingua.api.Language;
import com.github.pemistahl.lingua.api.LanguageDetector;
import com.github.pemistahl.lingua.api.LanguageDetectorBuilder;

import static com.github.pemistahl.lingua.api.Language.*;

public class Test {
    public static void detect(){
        LanguageDetector detector = LanguageDetectorBuilder.fromLanguages(ENGLISH, FRENCH, GERMAN, SPANISH).build();
        Language language = detector.detectLanguageOf("languages are awesome");
        System.out.println(language);
    }

    public static void main(String[] args) {
        detect();
    }
}

While running I am getting following exception:

Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/KotlinNothingValueException
	at kotlinx.serialization.SerializersKt.serializer(Unknown Source)
	at com.github.pemistahl.lingua.internal.TrainingDataLanguageModel$Companion.fromJson(TrainingDataLanguageModel.kt:150)
	at com.github.pemistahl.lingua.api.LanguageDetector.loadLanguageModel$lingua(LanguageDetector.kt:401)
	at com.github.pemistahl.lingua.api.LanguageDetector$loadLanguageModels$1.invoke(LanguageDetector.kt:407)
	at com.github.pemistahl.lingua.api.LanguageDetector$loadLanguageModels$1.invoke(LanguageDetector.kt:79)
	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
	at com.github.pemistahl.lingua.api.LanguageDetector.lookUpNgramProbability$lingua(LanguageDetector.kt:390)
	at com.github.pemistahl.lingua.api.LanguageDetector.computeSumOfNgramProbabilities$lingua(LanguageDetector.kt:366)
	at com.github.pemistahl.lingua.api.LanguageDetector.computeLanguageProbabilities$lingua(LanguageDetector.kt:353)
	at com.github.pemistahl.lingua.api.LanguageDetector.computeLanguageConfidenceValues(LanguageDetector.kt:162)
	at com.github.pemistahl.lingua.api.LanguageDetector.detectLanguageOf(LanguageDetector.kt:102)
	at com.tomtom.ssv.apt.ingestion.service.LanguageDetector.detect(LanguageDetector.java:67)
	at com.tomtom.ssv.apt.ingestion.service.LanguageDetector.main(LanguageDetector.java:72)
Caused by: java.lang.ClassNotFoundException: kotlin.KotlinNothingValueException
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 13 more

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
pemistahlcommented, Mar 9, 2021

It may be the user’s problem?

I think you are right but it’s not the user’s deliberate fault. The explicitly set Kotlin version in Spring Boot seems to overwrite the implicit Kotlin 1.4 dependency. But the user is not able to know about this because the error message is so unspecific.

I will simply add the explicit dependency to Kotlin 1.4 again in the next Lingua release. This should fix it once and for all. Thanks for your help @ahnqirage. Without you, I would not have found the cause so quickly.

0reactions
pemistahlcommented, Apr 24, 2021

I hope that I’ve fixed this now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

kotlin.KotlinNothingValueException using Android Studio 4.2 ...
kotlin :kotlin-test library with any version fails somehow. I use org.jetbrains.kotlin:kotlin-test-junit:1.4.30 on gradle and it passes all fine.
Read more >
Introduce KotlinNothingValueException and throw it instead of ...
Kotlin detected. NPE is thrown: Exception in thread "main" java.lang.NullPointerException at MainKt.decodeOut( main.kt:8 ) at MainKt.main( main.kt:12 ).
Read more >
NoClassDefFoundError on Kotlin class in JUnit test at runtime
My Kotlin class compiles and runs on an emulator without a problem. But when I test it, Android Studio says the class is...
Read more >
How can I fix random Kotlin exceptions when using the Java ...
NoClassDefFoundError :kotlin/KotlinNothingValueException). To fix this the first thing you should do is to investigate the project dependency tree as well as ...
Read more >
Kotlin: java.lang.NoClassDefFoundError: Could not ... - YouTube
Kotlin : java. lang. NoClassDefFoundError : Could not initialize class | IntelliJ IDEA Issue Solved. 11K views 1 year ago.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found