Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoClassDefFoundError on execution #2

Open
ToDelattre opened this issue Feb 8, 2021 · 4 comments
Open

java.lang.NoClassDefFoundError on execution #2

ToDelattre opened this issue Feb 8, 2021 · 4 comments

Comments

@ToDelattre
Copy link

ToDelattre commented Feb 8, 2021

Hello,
First of all, thanks for your work on this!

Here's my problem:

import com.github.frozencure.helix.HelixClient
import com.github.frozencure.helix.auth.model.AuthCredentials
import kotlinx.coroutines.runBlocking
import me.todelattre.Bot.TWITCH
import me.todelattre.config

val credentials = AuthCredentials(config[TWITCH])
val helixClient = HelixClient(credentials)

fun couille() {
    runBlocking {
        println(helixClient.users.getUser().resource.toString())
    }
}

Calling couille function in main() function and getting this error:

Exception in thread "main" java.lang.NoClassDefFoundError: io/ktor/http/ContentTypeMatcher
	at io.ktor.client.features.json.JsonFeature$Config.<init>(JsonFeature.kt:71)
	at io.ktor.client.features.json.JsonFeature$Feature.prepare(JsonFeature.kt:132)
	at io.ktor.client.features.json.JsonFeature$Feature.prepare(JsonFeature.kt:128)
        . . .
@frozencure
Copy link
Owner

Hi and thanks for using the library :)

At a first glance, this looks to me like a packaging/import problem. For some reason, the ContentTypeMatcher class could not be found. This class is part of the Ktor library, which might have not been imported properly.

How did you import the twitch-client library to your kotlin project? Did you use Maven or Gradle?

@ToDelattre
Copy link
Author

I used Maven as indicated in the README. By the way, i had to remove the type to make it work !
In the end, i followed your recommendations in the README and ended up with this problem.
Another thing i tried is downlaoding the jar and set it as a lib for my project, without success.

@frozencure
Copy link
Owner

Ok, that's weird, Maven should work. It might be a bug on the library side then, even though I remember that I tested it with Maven a while back and it worked. I will test the integration with a Maven project again tomorrow on my local machine. If it's really time-sensitive, you can fix it yourself and open a pull request. Also, please share the content of your pom.xml file, that might help me to debug it.

@ToDelattre
Copy link
Author

It's a personal project so it's ok :)
Here is my pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>me.todelattre</groupId>
    <artifactId>ShoutOut</artifactId>
    <version>0.0.1</version>

    <name>ShoutOut</name>

    <repositories>
        <repository>
            <id>central</id>
            <name>bintray</name>
            <url>https://jcenter.bintray.com</url>
        </repository>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
        <repository>
            <id>twitch-client-repo</id>
            <url>https://dl.bintray.com/frozencure/maven</url>
        </repository>
    </repositories>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <kotlin.version>1.4.30</kotlin.version>
        <kotlin.code.style>official</kotlin.code.style>
        <junit.version>4.12</junit.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib-jdk8</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-test-junit</artifactId>
            <version>${kotlin.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.jessecorbett</groupId>
            <artifactId>diskord-jvm</artifactId>
            <version>1.8.1</version>
        </dependency>
        <dependency>
            <groupId>com.uchuhimo</groupId>
            <artifactId>konf</artifactId>
            <version>0.22.1</version>
        </dependency>
        <dependency>
            <groupId>com.github.frozencure</groupId>
            <artifactId>twitch-client</artifactId>
            <version>0.0.1</version>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src/main/kotlin</sourceDirectory>
        <testSourceDirectory>src/test/kotlin</testSourceDirectory>

        <plugins>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${kotlin.version}</version>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <jvmTarget>1.8</jvmTarget>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants