爲什麼錯誤發生,我該如何解決?java.lang.LinkageError:嘗試重複的類定義
[02:13:02] [pool-4-thread-2/WARN]: Exception in thread "pool-4-thread-2"
[02:13:02] [pool-4-thread-2/WARN]: java.lang.LinkageError: loader (instance of org/bukkit/plugin/java/PluginClassLoader): attempted duplicate class definition for name: "com/mongodb/client/model/Filters"
[02:13:02] [pool-4-thread-2/WARN]: at java.lang.ClassLoader.defineClass1(Native Method)
[02:13:02] [pool-4-thread-2/WARN]: at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
[02:13:02] [pool-4-thread-2/WARN]: at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
[02:13:02] [pool-4-thread-2/WARN]: at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
[02:13:02] [pool-4-thread-2/WARN]: at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
[02:13:02] [pool-4-thread-2/WARN]: at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
[02:13:02] [pool-4-thread-2/WARN]: at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
[02:13:02] [pool-4-thread-2/WARN]: at java.security.AccessController.doPrivileged(Native Method)
[02:13:02] [pool-4-thread-2/WARN]: at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
[02:13:02] [pool-4-thread-2/WARN]: at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101)
[02:13:02] [pool-4-thread-2/WARN]: at org.bukkit.plugin.java.JavaPluginLoader.getClassByName(JavaPluginLoader.java:195)
[02:13:02] [pool-4-thread-2/WARN]: at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:97)
[02:13:02] [pool-4-thread-2/WARN]: at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86)
[02:13:02] [pool-4-thread-2/WARN]: at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[02:13:02] [pool-4-thread-2/WARN]: at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[02:13:02] [pool-4-thread-2/WARN]: at me.franzsan.data.mongo.MongoCharacter.existsCharacter(MongoCharacter.java:109)
[02:13:02] [pool-4-thread-2/WARN]: at me.franzsan.data.mongo.MongoCharacter.lambda$loadCharacter$0(MongoCharacter.java:44)
[02:13:02] [pool-4-thread-2/WARN]: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[02:13:02] [pool-4-thread-2/WARN]: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[02:13:02] [pool-4-thread-2/WARN]: at java.lang.Thread.run(Thread.java:745)
這是導致該錯誤
FindIterable cursor = connection.getCharacters().find(Filters.eq("uuid", uuid));
然後也有此行。它來自另一個模塊,兩者應該同時異步執行(或者相互之後不久,因爲我認爲現在我只有一個線程)。這個工作沒有錯誤。
FindIterable cursor = connection.getPlayers().find(Filters.eq("uuid", id));
Filters.eq是一種靜態方法。
兩者都使用相同的
ExecutorService pool = Executors.newCachedThreadPool();
我覺得我缺乏關鍵知識,我,但我不知道在哪裏看FO RIT。
你使用了一些不尋常的類加載設置? – immibis
我使用MongoCharacter類的接口和MongoPlayer類(工作代碼中的類)非常相似。 MongoCharacter類是問題還是加載Mongo驅動程序有問題? getPlayers()和getCharacters()都是從相同的MongoDatabase類派生的MongoCollection。 –
@ImranAli這不是'LinkageError'的子類。它*是一個'LinkageError'。 – EJP