project/lib フォルダーに 9 個の jar ファイルがあり、クラスパスは正確なようです。コンパイルする前はすべて正常に動作しますが、単一の jar stringtree-json-2.0.5.jar をコンパイルした後、実行しようとすると ClassNotFoundException がスローされます。
私が試したこと:
- 「*」を使用して lib フォルダー内のすべてを一度にロードする
- Jackson の使用から切り替えましたが (jar 固有であると仮定)、Stringtree にはまったく同じ問題があります。問題のある jar は、(重要な領域で) 一度だけ使用する json パーサーです。
- コンパイルの前後にクラスパスを変更して、正しいことを確認してみました。
- おそらくもっと多くのことを覚えていません...これに1週間ほど立ち往生しています。
スローされたときのエラーは次のとおりです。
org.bukkit.command.CommandException: Unhandled exception executing command 'rate' in plugin Pariah v1
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:189)
at org.bukkit.craftbukkit.v1_5_R2.CraftServer.dispatchCommand(CraftServer.java:523)
at net.minecraft.server.v1_5_R2.PlayerConnection.handleCommand(PlayerConnection.java:966)
at net.minecraft.server.v1_5_R2.PlayerConnection.chat(PlayerConnection.java:884)
at net.minecraft.server.v1_5_R2.PlayerConnection.a(PlayerConnection.java:841)
at net.minecraft.server.v1_5_R2.Packet3Chat.handle(Packet3Chat.java:44)
at net.minecraft.server.v1_5_R2.NetworkManager.b(NetworkManager.java:292)
at net.minecraft.server.v1_5_R2.PlayerConnection.d(PlayerConnection.java:110)
at net.minecraft.server.v1_5_R2.ServerConnection.b(SourceFile:35)
at net.minecraft.server.v1_5_R2.DedicatedServerConnection.b(SourceFile:30)
at net.minecraft.server.v1_5_R2.MinecraftServer.r(MinecraftServer.java:580)
at net.minecraft.server.v1_5_R2.DedicatedServer.r(DedicatedServer.java:225)
at net.minecraft.server.v1_5_R2.MinecraftServer.q(MinecraftServer.java:476)
at net.minecraft.server.v1_5_R2.MinecraftServer.run(MinecraftServer.java:409)
at net.minecraft.server.v1_5_R2.ThreadServerApplication.run(SourceFile:573)
Caused by: java.lang.NoClassDefFoundError: org/stringtree/json/JSONReader
at pariah.AllMethods.ratingCall(AllMethods.java:351)
at pariah.AllMethods.getPathRankRating(AllMethods.java:308)
at pariah.Pariah.onCommand(Pariah.java:63)
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
... 15 more
Caused by: java.lang.ClassNotFoundException: org.stringtree.json.JSONReader
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader.java:80)
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:53)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
... 19 more
これは私の現在のクラスパスです:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="test">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/commons-codec-1.6.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-logging-1.1.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/httpclient-4.2.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/httpclient-cache-4.2.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/httpcore-4.2.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/httpmime-4.2.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/stringtree-json-2.0.5.jar"/>
<classpathentry exported="true" kind="lib" path="lib/bukkit-1.5.1-R0.1-20130325.184829-14.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
私はEclipseを使用して開発とコンパイルを行っています。これを解決するために繰り返し提案されることの 1 つは、プロジェクトを実行可能な Jar ファイルとしてエクスポートすることです。ただし、これはプラグインであるため、「メイン」メソッドはありません。
そこに他のアイデアはありますか?私は(...私自身と)グーグルとスタックオーバーフローで見つけたすべてのオプションを使い果たしたと感じています。
ありがとう!