NoClassDefFoundError:由ClassNotFoundException

时间:2018-04-15 14:08:19

标签: java noclassdeffounderror classnotfoundexception

我的程序在运行时存在时可能会使用库,但不需要使用此库来运行程序。但是,当我运行我的程序(没有库存在)时,它会抱怨它不适用于非常具体的导入:

    java.lang.NoClassDefFoundError: nl/lolmewn/stats/api/storage/StorageException
        at me.staartvin.plugins.pluginlibrary.Library.<clinit>(Library.java:34) ~[?:?]
        at me.staartvin.plugins.pluginlibrary.PluginLibrary.loadLibraries(PluginLibrary.java:105) ~[?:?]
        at me.staartvin.plugins.pluginlibrary.PluginLibrary.onEnable(PluginLibrary.java:68) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-latest.jar:git-Spigot-eadd615-4509a14]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337) [spigot-latest.jar:git-Spigot-eadd615-4
9a14]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403) [spigot-latest.jar:git-Spigot-eadd615-
09a14]
        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:381) [spigot-latest.jar:git-Spigot-eadd615-45
a14]
        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:330) [spigot-latest.jar:git-Spigot-eadd615-4
9a14]
        at net.minecraft.server.v1_12_R1.MinecraftServer.t(MinecraftServer.java:422) [spigot-latest.jar:git-Spigot-eadd615-4509a14
        at net.minecraft.server.v1_12_R1.MinecraftServer.l(MinecraftServer.java:383) [spigot-latest.jar:git-Spigot-eadd615-4509a14
        at net.minecraft.server.v1_12_R1.MinecraftServer.a(MinecraftServer.java:338) [spigot-latest.jar:git-Spigot-eadd615-4509a14
        at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:272) [spigot-latest.jar:git-Spigot-eadd615-4509
4]
        at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:545) [spigot-latest.jar:git-Spigot-eadd615-4509a
]
        at java.lang.Thread.run(Uenter code herenknown Source) [?:1.8.0_161]
Caused by: java.lang.ClassNotFoundException: nl.lolmewn.stats.api.storage.StorageException
        at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_161]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:152) ~[spigot-latest.jar:git-Spigot-eadd615-4
9a14]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:100) ~[spigot-latest.jar:git-Spigot-eadd615-4
9a14]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_161]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_161]
        ... 14 more

使用此 StorageException 类的代码是:

try {
    user = stats.getUserManager().loadUser(player.getUniqueId(), stats.getStatManager());
} catch (StorageException e) {
    e.printStackTrace();
}

请注意,我使用此库有很多导入。奇怪的是,当我省略 StorageException 导入时(例如将其更改为一般 Exception ),它不会给出任何错误,即使有其他导入(来自完全相同的库)现在

显然,我想使用StorageException类来捕获错误,但我似乎无法做到这一点。

我该如何解决这个问题?

0 个答案:

没有答案