java.lang.LinkageError:尝试重复的类定义

时间:2016-07-25 00:45:23

标签: java 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();

我觉得自己缺乏关键知识,但我不知道该去哪里看。

1 个答案:

答案 0 :(得分:0)

duplicate class definition for name说全部。您似乎在类插件com.mongodb.client下的插件中复制了mongodb驱动程序,就像在其他插件中一样,并且您在同一台服务器上运行这两个插件。这会导致冲突,因为您尝试使用完全相同的类路径加载2个类。