NyaaCat / NyaaCore

Code infrastructure for all NyaaCat plugins
MIT License
22 stars 12 forks source link

Compile time warnings might result in database runtime error of HEH #33

Closed Akiranya closed 5 years ago

Akiranya commented 5 years ago

在 branch 1.14 下用 gradle 编译 commit 4dfc503a61e1da4bc4716c8babaa5748ea5073e0 会提示如下 warnings:

12:11:58: Executing task 'jar'...

> Task :compileJava
Note: Lang resources directory: /Users/chencu/IdeaProjects/bukkit-projects/NyaaCore/src/main/resources/lang
Note: Loaded lang files:
Note: /Users/chencu/IdeaProjects/bukkit-projects/NyaaCore/src/main/resources/lang/en_US.yml
/Users/chencu/IdeaProjects/bukkit-projects/NyaaCore/src/main/java/cat/nyaa/nyaacore/configuration/ISerializable.java:144: warning: [deprecation] newInstance() in Class has been deprecated
                    ISerializable o = (ISerializable) cls.newInstance();
                                                         ^
  where T is a type-variable:
    T extends Object declared in class Class
/Users/chencu/IdeaProjects/bukkit-projects/NyaaCore/src/main/java/cat/nyaa/nyaacore/configuration/ISerializable.java:159: warning: [deprecation] newInstance() in Class has been deprecated
                            ISerializable o = (ISerializable) cls.newInstance();
                                                                 ^
  where T is a type-variable:
    T extends Object declared in class Class
/Users/chencu/IdeaProjects/bukkit-projects/NyaaCore/src/main/java/cat/nyaa/nyaacore/database/provider/SQLiteDatabase.java:118: warning: [rawtypes] found raw type: TableStructure
        TableStructure ts = TableStructure.fromClass(cls);
        ^
  missing type arguments for generic class TableStructure<T>
  where T is a type-variable:
    T extends Object declared in class TableStructure
/Users/chencu/IdeaProjects/bukkit-projects/NyaaCore/src/main/java/cat/nyaa/nyaacore/database/provider/SQLiteDatabase.java:119: warning: [deprecation] getCreateTableSQL(String) in TableStructure has been deprecated
        String sql = ts.getCreateTableSQL("sqlite");
                       ^
/Users/chencu/IdeaProjects/bukkit-projects/NyaaCore/src/main/java/cat/nyaa/nyaacore/utils/ItemStackUtils.java:33: warning: [deprecation] getUnsafe() in Bukkit has been deprecated
        currentDataVersion = Bukkit.getUnsafe().getDataVersion();
                                   ^
5 warnings

> Task :processResources
> Task :classes
> Task :jar

BUILD SUCCESSFUL in 0s
3 actionable tasks: 3 executed
12:11:59: Task execution finished 'jar'.

虽然最后 build 成功了,但这个问题似乎导致 HEH 无法正常调用数据库的相关方法(sqlite 和 mysql 都不行)。HEH 在服务端启动时会提示如下错误:

[12:19:23 INFO]: [HamsterEcoHelper] Enabling HamsterEcoHelper v6.4.x
[12:19:23 INFO]: [HamsterEcoHelper] Now using language: en_US
[12:19:23 WARN]: Fri Jun 28 12:19:23 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
[12:19:23 INFO]: Updating database, this may take some time
[12:19:23 ERROR]: Error occurred while enabling HamsterEcoHelper v6.4.x (Is it up to date?)
java.lang.NoClassDefFoundError: javax/persistence/Table
    at cat.nyaa.nyaacore.database.relational.TableStructure.<init>(TableStructure.java:39) ~[?:?]
    at cat.nyaa.nyaacore.database.relational.TableStructure.fromClass(TableStructure.java:21) ~[?:?]
    at cat.nyaa.nyaacore.database.relational.BaseDatabase.createTable(BaseDatabase.java:115) ~[?:?]
    at cat.nyaa.nyaacore.database.provider.MysqlDatabase.queryTransactional(MysqlDatabase.java:85) ~[?:?]
    at cat.nyaa.nyaacore.database.provider.MysqlDatabase.queryTransactional(MysqlDatabase.java:15) ~[?:?]
    at cat.nyaa.HamsterEcoHelper.database.DatabaseUpdater.updateVersion0To1(DatabaseUpdater.java:38) ~[?:?]
    at cat.nyaa.HamsterEcoHelper.database.DatabaseUpdater.updateDatabase(DatabaseUpdater.java:15) ~[?:?]
    at cat.nyaa.HamsterEcoHelper.database.Database.<init>(Database.java:27) ~[?:?]
    at cat.nyaa.HamsterEcoHelper.HamsterEcoHelper.onEnable(HamsterEcoHelper.java:55) ~[?:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.14.3.jar:git-Paper-114]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:338) ~[patched_1.14.3.jar:git-Paper-114]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:419) ~[patched_1.14.3.jar:git-Paper-114]
    at org.bukkit.craftbukkit.v1_14_R1.CraftServer.enablePlugin(CraftServer.java:464) ~[patched_1.14.3.jar:git-Paper-114]
    at org.bukkit.craftbukkit.v1_14_R1.CraftServer.enablePlugins(CraftServer.java:378) ~[patched_1.14.3.jar:git-Paper-114]
    at net.minecraft.server.v1_14_R1.MinecraftServer.a(MinecraftServer.java:464) ~[patched_1.14.3.jar:git-Paper-114]
    at net.minecraft.server.v1_14_R1.DedicatedServer.init(DedicatedServer.java:282) ~[patched_1.14.3.jar:git-Paper-114]
    at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:859) ~[patched_1.14.3.jar:git-Paper-114]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212]
Caused by: java.lang.ClassNotFoundException: javax.persistence.Table
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[?:1.8.0_212]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:139) ~[patched_1.14.3.jar:git-Paper-114]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:85) ~[patched_1.14.3.jar:git-Paper-114]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_212]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_212]
    ... 18 more
[12:19:23 INFO]: [HamsterEcoHelper] Disabling HamsterEcoHelper v6.4.x
[12:19:23 ERROR]: Error occurred while disabling HamsterEcoHelper v6.4.x (Is it up to date?)
java.lang.NullPointerException: null
    at cat.nyaa.HamsterEcoHelper.HamsterEcoHelper.onDisable(HamsterEcoHelper.java:77) ~[?:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:265) ~[patched_1.14.3.jar:git-Paper-114]
    at org.bukkit.plugin.java.JavaPluginLoader.disablePlugin(JavaPluginLoader.java:373) ~[patched_1.14.3.jar:git-Paper-114]
    at org.bukkit.plugin.SimplePluginManager.disablePlugin(SimplePluginManager.java:452) ~[patched_1.14.3.jar:git-Paper-114]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[patched_1.14.3.jar:git-Paper-114]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:419) ~[patched_1.14.3.jar:git-Paper-114]
    at org.bukkit.craftbukkit.v1_14_R1.CraftServer.enablePlugin(CraftServer.java:464) ~[patched_1.14.3.jar:git-Paper-114]
    at org.bukkit.craftbukkit.v1_14_R1.CraftServer.enablePlugins(CraftServer.java:378) ~[patched_1.14.3.jar:git-Paper-114]
    at net.minecraft.server.v1_14_R1.MinecraftServer.a(MinecraftServer.java:464) ~[patched_1.14.3.jar:git-Paper-114]
    at net.minecraft.server.v1_14_R1.DedicatedServer.init(DedicatedServer.java:282) ~[patched_1.14.3.jar:git-Paper-114]
    at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:859) ~[patched_1.14.3.jar:git-Paper-114]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212]

HEH 关于数据库的配置如下:

database:
  provider: mysql
  connection:
    autoscan: true
    url: jdbc:MySQL://localhost:3306/heh
    username: root

注:HEH 用的是 branch master 下 commit 7f4e05c3a0a0c483fc4c663bd4513c7a9e92baad 编译的。

cyilin commented 5 years ago

你需要运行shadowJar任务来生成完整的nyaacore jar