lavalink-devs / lavaplayer

Lavaplayer fork maintained by Lavalink
Apache License 2.0
187 stars 51 forks source link

[v2.1.1] NoSuchMethodError on ByteBuffer when trying to play a track #80

Closed VadamDev closed 7 months ago

VadamDev commented 7 months ago

Versions

Description

Hello, When trying to play any track, I keep getting NSM on ByteBuffer (see stacktrace) even after mentionning in my gradle file that the source/target compatibility is Java 8

Stacktrace

[LocalAudioTrackExecutor/ERROR]: Error in playback of mLxI-q9Fi0s com.sedmelluq.discord.lavaplayer.tools.FriendlyException: Something broke when playing the track. at com.sedmelluq.discord.lavaplayer.tools.ExceptionTools.wrapUnfriendlyExceptions(ExceptionTools.java:45) at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.execute(LocalAudioTrackExecutor.java:113) at com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager.lambda$executeTrack$2(DefaultAudioPlayerManager.java:330) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:750) Caused by: java.lang.NoSuchMethodError: java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer; at com.sedmelluq.discord.lavaplayer.container.matroska.format.MutableMatroskaBlock.getNextFrameBuffer(MutableMatroskaBlock.java:56) at com.sedmelluq.discord.lavaplayer.container.matroska.MatroskaStreamingFile.processFrameInBlock(MatroskaStreamingFile.java:368) at com.sedmelluq.discord.lavaplayer.container.matroska.MatroskaStreamingFile.parseClusterSimpleBlock(MatroskaStreamingFile.java:332) at com.sedmelluq.discord.lavaplayer.container.matroska.MatroskaStreamingFile.parseNextCluster(MatroskaStreamingFile.java:317) at com.sedmelluq.discord.lavaplayer.container.matroska.MatroskaStreamingFile.provideFrames(MatroskaStreamingFile.java:293) at com.sedmelluq.discord.lavaplayer.container.matroska.MatroskaAudioTrack.lambda$process$0(MatroskaAudioTrack.java:40) at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.executeProcessingLoop(LocalAudioTrackExecutor.java:284) at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.executeProcessingLoop(LocalAudioTrackExecutor.java:257) at com.sedmelluq.discord.lavaplayer.container.matroska.MatroskaAudioTrack.process(MatroskaAudioTrack.java:39) at com.sedmelluq.discord.lavaplayer.track.DelegatedAudioTrack.processDelegate(DelegatedAudioTrack.java:25) at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioTrack.processStatic(YoutubeAudioTrack.java:64) at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioTrack.process(YoutubeAudioTrack.java:51) at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.execute(LocalAudioTrackExecutor.java:101)

build.gradle

plugins {
    id 'java'
    id 'application'
    id 'com.github.johnrengelman.shadow' version '8.0.0'
}

application.mainClass = "net.vadamdev.jafarbot.Main"
group 'net.vadamdev.jafarbot'
version '2.4.2'

repositories {
    mavenCentral()

    maven {
        url 'https://jitpack.io'
    }
}

dependencies {
    implementation group: 'net.dv8tion', name: 'JDA', version: '5.0.0-beta.21'
    implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.3.14'

    implementation group: 'dev.arbjerg', name:'lavaplayer', version:'2.1.1'

    implementation group: 'me.carleslc.Simple-YAML', name: 'Simple-Yaml', version: '1.8.4'
    implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
    implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
    implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
}

java {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

compileJava.options.encoding = 'UTF-8'
devoxin commented 7 months ago

Try using a newer version of Java

VadamDev commented 7 months ago

Hello. It works on Java 17. But what if i wanna keep using Java 8 ? :x This errors occurs when the build bytecode is in Java9+ since they changed the ByteBuffer class (see: https://www.morling.dev/blog/bytebuffer-and-the-dreaded-nosuchmethoderror/)

But the source compatiblity in the Lavaplayer build.gradle file is Java 8 (line 36) so i guess just adding targetCompatibility = JavaVersion.VERSION_1_8 would fix the issue

Otherwise, it would be cool to mention what minimum version of Java you need to use this fork ^^'

devoxin commented 7 months ago

But what if i wanna keep using Java 8 ? :x

Unless you have a specific requirement that forces you to use Java 8 I would really advise you upgrade. Aside from legacy software there's no real reason to continue using such an outdated version

VadamDev commented 7 months ago

It's not a issue for this project, I can update but I have other legacy bots that I will need to update which will take time :x Would be cool to have a fix honestly

devoxin commented 7 months ago

Could you give 08fe37dad9c0a2bb42240dab5401726cada0cc95 a try and see if it fixes your issue?

VadamDev commented 7 months ago

Still get the same error (Same bot, JVM version etc...)

Gradle file juste in case:

dependencies {
    implementation 'com.github.lavalink-devs:lavaplayer:set-target-compatibility-SNAPSHOT'
}

tasks.withType(Tar).configureEach {
    duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

tasks.withType(Zip).configureEach {
    duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
devoxin commented 7 months ago

34f8ca076291ba4c0a1c98f50da91520874f33cc?

VadamDev commented 7 months ago

Same issue

VadamDev commented 7 months ago

Out of curiosity, I tried your fork (https://github.com/devoxin/lavaplayer) and it works with Java 8

devoxin commented 7 months ago

I'd just stick with my fork then tbh. There's speculation as to whether we leverage Java language features from versions after 8, or it could equally be due to a fault in how Gradle is being configured to compile the project, but extensive testing isn't worth it as I think the general consensus is that we don't want to retain support for super old Java versions so are ultimately looking at bumping the minimum version required to 11.

Just keep in mind with my fork, that it's missing a lot of the custom stuff like audio track isrcs and artwork URLs. If you don't need that then it should be no issue.

I'm going to go ahead and close this issue as I don't think there's much more to be said. If there is, you're free to join the Lavalink Discord server