when call js refresh() the scriptcraft stop working
falcomsgy opened this issue ยท 3 comments
I find sometimes when I call /js refresh() in the Minecraft. There are some errors happened, then I can not run any command start with js until restart whole server. The error message like following
[Server thread/ERROR]: [scriptcraft] java.lang.NoSuchMethodException: No such function __onCommand
Then I check the logs for more context:
[14:19:11] [Server thread/INFO]: player3 issued server command: /js refresh()
[14:19:11] [Server thread/INFO]: [scriptcraft] Disabling scriptcraft v3.2.0-2016-03-19
[14:19:11] [Server thread/ERROR]: Could not pass event PluginDisableEvent to scriptcraft v3.2.0-2016-03-19
java.lang.RuntimeException: java.io.FileNotFoundException: /home/zgyd_01/mcserver/scriptcraft/data/signs-store.json (No such file or directory)
....
[14:19:11] [Server thread/INFO]: [scriptcraft] Enabling scriptcraft v3.2.0-2016-03-19
[14:19:11] [Server thread/WARN]: Enabled plugin with unregistered PluginClassLoader scriptcraft v3.2.0-2016-03-19
[14:19:11] [Server thread/WARN]: java.lang.NullPointerException
I notice similar issue in 2014, but have fixed. More information for debug
my server is SpigotMC 1.10.2 compiled by java 1.8.0_72
OS is ubuntu 14.04, kernel 3.19
Thanks a lot
I update my server to 1.11.2 and use the latest plugin. I still find the issue when I call js refresh() sometimes. The key detail info likes following:
[19:35:16] [Server thread/ERROR]: Could not pass event PluginDisableEvent to scriptcraft v3.2.1-2016-12-23
java.lang.RuntimeException: java.io.FileNotFoundException: /home/zgyd_01/mcserver3/scriptcraft/data/signs-store.json (No such file or directory)
at org.bukkit.plugin.EventExecutor$$NashornJavaAdapter.execute(Unknown Source) ~[?:?]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-622add8]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.11.2.jar:git-Spigot-7d78b81-622add8]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.11.2.jar:git-Spigot-7d78b81-622add8]
at org.bukkit.plugin.java.JavaPluginLoader.disablePlugin(JavaPluginLoader.java:355) [spigot-1.11.2.jar:git-Spigot-7d78b81-622add8]
.....
[19:35:16] [Server thread/INFO]: [scriptcraft] Enabling scriptcraft v3.2.1-2016-12-23
[19:35:16] [Server thread/WARN]: Enabled plugin with unregistered PluginClassLoader scriptcraft v3.2.1-2016-12-23
[19:35:16] [Server thread/WARN]: java.lang.NullPointerException
[19:35:16] [Server thread/WARN]: at java.io.Reader.(Reader.java:78)
19:35:16] [Server thread/WARN]: at net.minecraft.server.v1_11_R1.SystemUtils.a(SourceFile:46)
[19:35:16] [Server thread/WARN]: at net.minecraft.server.v1_11_R1.MinecraftServer.D(MinecraftServer.java:739)
[19:35:16] [Server thread/WARN]: at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:399)
[19:35:16] [Server thread/WARN]: at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:675)
[19:35:16] [Server thread/WARN]: at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:574)
[19:35:16] [Server thread/WARN]: at java.lang.Thread.run(Thread.java:745)
[19:35:16] [Server thread/ERROR]: [scriptcraft] null
[19:35:27] [Server thread/INFO]: player3 issued server command: /js
[19:35:27] [Server thread/ERROR]: [scriptcraft] java.lang.NoSuchMethodException: No such function __onCommand
I want to know whether we have some other commands to instead of js refresh(). Or could you share some experience to avoid the issue.
Thanks a lot
About the file missing error:
I think your file system changed sometime after initial load. Create a folder:
/home/zgyd_01/mcserver3/scriptcraft/data/
And are you using the signs.js functionality? It's possible that there is/was a bug in the persistence code which does not create that folder automatically.
There should be other .json files in that folder: alias-store.json, global-config.json, etc. Is the signs-store.json file there? If it is, are the permissions for all files 0660 or maybe 0770?
About No such function __onCommand:
I think this means the ScriptCraftPlugin class can't find the __onCommand() function in the scriptcraft.js file. That could also point to a file or folder permissions issue.
I recommend:
- Stop the server.
- Move ALL scriptcraft folders and files to a new temp folder.
- Restart and check for issues. Make sure there are no external references or dependencies on ScriptCraft.
- Stop the server.
- Download and install the latest ScriptCraft from here or the download area.
- Restart. And check for errors.
- Stop the server again and check for errors.
- Now restart and try /js refresh().
- Load back specific scripts that you need, one by one.
- Do a refresh after each one.
- Either there will be no errors, or after one of these steps you may find an error, and that will point to the source of the problem.
@TonyGravagno Thanks your kind reply. i did some tests to try to answer your questions.
i create a clean environment with spigot-1.11.2.jar and latest version scriptcraft modified @ Dec-23-2016. After start server, then i stop it. I find the myserver/scriptcraft/data folder created and contains following files
alias-store.json
arrows-store.json
classroom-store.json
global-config.json
homes-store.json
signs-store.json
the permissions of all files are 664.
Every time when the error happens, i check the file signs-store.json, it does not missing. BTW, the content in the signs-store.json are always "{}". To my knowledge, we do not use the signs.js, at least do not use it directly. I am not sure whether we use it indirectly.
For can't find the __onCommand, i read the log carefully, i think the reason is that when enable the plugin scriptcraft, the plugin manager can not find the plugin correctly and return null pointer. But I am not sure where the root cause, because if error happened, the 4 working steps in refresh(): disable plugin, stop event, stop task and enable plugin, all of them have some errors and warnings. And i try to identify the each errors or warnings and read the previous issues, i find maybe you are right, it caused by some specific script. Now my server open to some kids for write their own program, they usually write some mistake code as freshman of program. However i need sometime to find which code cause this issue.
i will try to find the root cause continually according to your suggestions. If any progress i will post my finding in this issue.
Thanks again
Guanyi