質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
JAR

JAR(又はJava ARchive)はコンパイルされた複数のJavaバイトコード及び関連ファイルのリソースを一つのファイルに統合したものです。JARファイルはZIPファイルのフォーマットで構築されています。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

IntelliJ IDEA

IntelliJ IDEA(インテリジェイ アイディア)は、JetBrains社が開発した、 JavaやScalaなどで利用される統合開発環境です。

Gradle

Gradleは、ビルド自動化ツールです。 ソフトウェアパッケージやドキュメント、 または実際に何か他の種類のプロジェクトの構築、テスト、公開、展開などを自動化が出来ます

Kotlin

Kotlinは、ジェットブレインズ社のアンドリー・ブレスラフ、ドミトリー・ジェメロフが開発した、 静的型付けのオブジェクト指向プログラミング言語です。

Q&A

0回答

1949閲覧

Jacksonでjava.lang.NoClassDefFoundErrorが出る

neopm

総合スコア0

JAR

JAR(又はJava ARchive)はコンパイルされた複数のJavaバイトコード及び関連ファイルのリソースを一つのファイルに統合したものです。JARファイルはZIPファイルのフォーマットで構築されています。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

IntelliJ IDEA

IntelliJ IDEA(インテリジェイ アイディア)は、JetBrains社が開発した、 JavaやScalaなどで利用される統合開発環境です。

Gradle

Gradleは、ビルド自動化ツールです。 ソフトウェアパッケージやドキュメント、 または実際に何か他の種類のプロジェクトの構築、テスト、公開、展開などを自動化が出来ます

Kotlin

Kotlinは、ジェットブレインズ社のアンドリー・ブレスラフ、ドミトリー・ジェメロフが開発した、 静的型付けのオブジェクト指向プログラミング言語です。

0グッド

1クリップ

投稿2021/05/09 06:02

前提・実現したいこと

Jacksonをプログラム内で使用したいです。

Gradleでjacksonを導入したが、jarを実行するとNoClassDefFoundErrorが出てしまいます。

これは、MinecraftのMODですが、今回のエラーは普通のGradleプロジェクトと変わらないと思ったので、このように質問させていただきます。

発生している問題・エラーメッセージ

net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from CrTea Client (crtea) Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ObjectMapper at cf.crocha.crtea.api.ApiManager.<init>(ApiManager.java:36) at cf.crocha.crtea.CrTea.startClient(CrTea.java:63) at cf.crocha.crtea.CrTea.init(CrTea.java:47) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:637) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) at com.google.common.eventbus.EventBus.post(EventBus.java:217) at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:219) at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:197) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) at com.google.common.eventbus.EventBus.post(EventBus.java:217) at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:136) at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:749) at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:336) at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:535) at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:378) at net.minecraft.client.main.Main.main(SourceFile:123) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ObjectMapper at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:101) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 44 more

該当のソースコード

build.gradle

1buildscript { 2 repositories { 3 jcenter() 4 maven { 5 name = "forge" 6 url = "http://files.minecraftforge.net/maven" 7 } 8 maven { 9 name = 'SpongePowered' 10 url = 'https://repo.spongepowered.org/repository/maven-public/' 11 } 12 maven { 13 name = 'lukflug' 14 url = 'https://lukflug.github.io/maven/' 15 } 16 } 17 dependencies { 18 classpath "net.minecraftforge.gradle:ForgeGradle:3+" 19 classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT' 20 classpath "com.github.jengelman.gradle.plugins:shadow:4.0.4" 21 } 22} 23apply plugin: "net.minecraftforge.gradle" 24apply plugin: 'org.spongepowered.mixin' 25apply plugin: "com.github.johnrengelman.shadow" 26 27version project.modVersion 28group project.modGroup 29 30minecraft { 31 mappings channel: 'stable', version: '39-1.12' 32} 33 34repositories { 35 maven { 36 name = 'spongepowered-repo' 37 url = 'https://repo.spongepowered.org/repository/maven-public/' 38 } 39 maven { 40 name = 'swt-repo' 41 url = "https://maven-eclipse.github.io/maven" 42 } 43 maven { 44 name = "jitpack.io" 45 url = "https://jitpack.io" 46 } 47 maven { 48 name = 'lukflug' 49 url = 'https://lukflug.github.io/maven' 50 } 51 mavenCentral() 52 jcenter() 53} 54 55dependencies { 56 // minecraftforge dependency 57 minecraft "net.minecraftforge:forge:1.12.2-14.23.5.2854" 58 59 shadow "com.mojang:brigadier:1.0.17" 60 shadow "com.github.Vatuu:discord-rpc:1.6.2" 61 62 // mixins 63 implementation "org.spongepowered:mixin:0.7.11-SNAPSHOT" 64 shadow("org.spongepowered:mixin:0.7.11-SNAPSHOT") { 65 exclude module: "launchwrapper" 66 exclude module: "guava" 67 exclude module: "gson" 68 exclude module: "commons-io" 69 } 70 annotationProcessor("org.spongepowered:mixin:0.8.2:processor") { 71 exclude module: "gson" 72 } 73 74 implementation "com.github.ZeroMemes:Alpine:1.5" 75 shadow "com.github.ZeroMemes:Alpine:1.5" 76 77 implementation('com.lukflug:panelstudio:0.1.8') 78 implementation('com.lukflug:panelstudio-mc12:0.1.8') 79 shadow('com.lukflug:panelstudio:0.1.8') 80 shadow('com.lukflug:panelstudio-mc12:0.1.8') 81 82 implementation 'com.fasterxml.jackson.core:jackson-core:2.9.4' 83 shadow('com.fasterxml.jackson.core:jackson-core:2.9.4') 84 implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.4' 85 shadow('com.fasterxml.jackson.core:jackson-annotations:2.9.4') 86 implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.4' 87 shadow('com.fasterxml.jackson.core:jackson-databind:2.9.4') 88} 89 90processResources { 91 // this will ensure that this task is redone when the versions change. 92 inputs.property "version", project.version 93 94 // replace stuff in mcmod.info, nothing else 95 from(sourceSets.main.resources.srcDirs) { 96 include "mcmod.info" 97 98 // replace version and mcversion 99 expand "version": project.version 100 } 101 102 // copy everything else, thats not the mcmod.info 103 from(sourceSets.main.resources.srcDirs) { 104 exclude "mcmod.info" 105 } 106} 107 108shadowJar { 109 configurations = [project.configurations.shadow] 110 exclude("dummyThing") 111 exclude("LICENSE.txt") 112 setClassifier("release") 113} 114 115mixin { 116 defaultObfuscationEnv "searge" 117 add sourceSets.main, "mixins.crtea.refmap.json" 118} 119 120reobf { 121 shadowJar { 122 classpath = sourceSets.main.compileClasspath 123 } 124} 125 126jar { 127 manifest { 128 attributes( 129 "MixinConfigs": "mixins.crtea.json", 130 "TweakClass": "org.spongepowered.asm.launch.MixinTweaker", 131 "TweakOrder": 0, 132 "FMLCorePluginContainsFMLMod": "true", 133 "FMLCorePlugin": "cf.crocha.crtea.mixin.MixinLoaderForge", 134 "ForceLoadAsMod": "true" 135 ) 136 } 137} 138 139build.dependsOn(shadowJar) 140 141import java.nio.file.* 142 143task copyJarToDebug { 144 dependsOn "build" 145 group 'fg_runs' 146 doFirst { 147 Path from = Paths.get("${projectDir}/build/libs/crtea-${project.version}-release.jar") 148 Path to = Paths.get("${projectDir}/debug/mods/crtea.jar") 149 Files.copy(from, to, StandardCopyOption.REPLACE_EXISTING) 150 } 151}

試したこと

Jacksonのバージョンを変えてみた。
annotationとcoreを入れた状態、入れていない状態で試した。

補足情報(FW/ツールのバージョンなど)

gradle 5.6.4

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問