ClassCastException when trying to run a script

Discussion in 'CraftScripts' started by jammasterz, Jul 9, 2015.

  1. jammasterz

    jammasterz New Member

    Hello. I'm new to the scripts and I'm having a problem I've been trying to solve for a few hours now. I'm running worldedit on Forge. I downloaded rhino and placed it in the mods folder next to the worldedit jar, and placed the bundled scripts in config/worldedit/craftscripts. Then when i tried to run maze.js by doing /cs maze.js wool 2 i got ClassCastException error in chat. The full error log from the console is:

    Code (Text):
    WARNING: [WorldEdit] Failed to execute script
    java.lang.ClassCastException: org.mozilla.javascript.NativeJavaClass cannot be cast to org.mozilla.javascript.NativeJavaPackage
        at org.mozilla.javascript.NativeJavaTopPackage.init(NativeJavaTopPackage.java:96)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.mozilla.javascript.ScriptableObject.buildClassCtor(ScriptableObject.java:1225)
        at org.mozilla.javascript.LazilyLoadedCtor.buildValue0(LazilyLoadedCtor.java:105)
        at org.mozilla.javascript.LazilyLoadedCtor.access$000(LazilyLoadedCtor.java:18)
        at org.mozilla.javascript.LazilyLoadedCtor$1.run(LazilyLoadedCtor.java:90)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.mozilla.javascript.LazilyLoadedCtor.buildValue(LazilyLoadedCtor.java:86)
        at org.mozilla.javascript.LazilyLoadedCtor.init(LazilyLoadedCtor.java:66)
        at org.mozilla.javascript.ScriptableObject$GetterSlot.getValue(ScriptableObject.java:307)
        at org.mozilla.javascript.ScriptableObject.get(ScriptableObject.java:456)
        at org.mozilla.javascript.IdScriptableObject.get(IdScriptableObject.java:329)
        at org.mozilla.javascript.ImporterTopLevel.get(ImporterTopLevel.java:96)
        at org.mozilla.javascript.ScriptableObject.getProperty(ScriptableObject.java:2184)
        at org.mozilla.javascript.ScriptRuntime.topScopeName(ScriptRuntime.java:1824)
        at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1726)
        at org.mozilla.javascript.gen.C__Users_Wawrzyn_AppData_Roaming__minecraft_instances_1_8_Forge_config_worldedit_craftscripts_maze_js_1._c_script_0(C:\Users\Wawrzyn\AppData\Roaming\.minecraft\instances\1.8 Forge\config\worldedit\craftscripts\maze.js:20)
        at org.mozilla.javascript.gen.C__Users_Wawrzyn_AppData_Roaming__minecraft_instances_1_8_Forge_config_worldedit_craftscripts_maze_js_1.call(C:\Users\Wawrzyn\AppData\Roaming\.minecraft\instances\1.8 Forge\config\worldedit\craftscripts\maze.js)
        at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
        at com.sk89q.worldedit.scripting.RhinoContextFactory.doTopCall(RhinoContextFactory.java:58)
        at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
        at org.mozilla.javascript.gen.C__Users_Wawrzyn_AppData_Roaming__minecraft_instances_1_8_Forge_config_worldedit_craftscripts_maze_js_1.call(C:\Users\Wawrzyn\AppData\Roaming\.minecraft\instances\1.8 Forge\config\worldedit\craftscripts\maze.js)
        at org.mozilla.javascript.gen.C__Users_Wawrzyn_AppData_Roaming__minecraft_instances_1_8_Forge_config_worldedit_craftscripts_maze_js_1.exec(C:\Users\Wawrzyn\AppData\Roaming\.minecraft\instances\1.8 Forge\config\worldedit\craftscripts\maze.js)
        at org.mozilla.javascript.Context.evaluateString(Context.java:1079)
        at com.sk89q.worldedit.scripting.RhinoCraftScriptEngine.evaluate(RhinoCraftScriptEngine.java:60)
        at com.sk89q.worldedit.WorldEdit.runScript(WorldEdit.java:761)
        at com.sk89q.worldedit.command.ScriptingCommands.execute(ScriptingCommands.java:78)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.sk89q.worldedit.util.command.parametric.ParametricCallable.call(ParametricCallable.java:243)
        at com.sk89q.worldedit.util.command.SimpleDispatcher.call(SimpleDispatcher.java:125)
        at com.sk89q.worldedit.extension.platform.CommandManager.handleCommand(CommandManager.java:225)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.sk89q.worldedit.util.eventbus.MethodEventHandler.dispatch(MethodEventHandler.java:58)
        at com.sk89q.worldedit.util.eventbus.EventHandler.handleEvent(EventHandler.java:73)
        at com.sk89q.worldedit.util.eventbus.EventBus.dispatch(EventBus.java:187)
        at com.sk89q.worldedit.util.eventbus.EventBus.post(EventBus.java:173)
        at com.sk89q.worldedit.forge.ForgeWorldEdit.onCommandEvent(ForgeWorldEdit.java:141)
        at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_44_ForgeWorldEdit_onCommandEvent_CommandEvent.invoke(.dynamic)
        at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55)
        at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:138)
        at net.minecraft.command.CommandHandler.func_71556_a(CommandHandler.java:52)
        at net.minecraft.network.NetHandlerPlayServer.func_147361_d(NetHandlerPlayServer.java:812)
        at net.minecraft.network.NetHandlerPlayServer.func_147354_a(NetHandlerPlayServer.java:791)
        at net.minecraft.network.play.client.C01PacketChatMessage.func_180757_a(SourceFile:37)
        at net.minecraft.network.play.client.C01PacketChatMessage.func_148833_a(SourceFile:9)
        at net.minecraft.network.PacketThreadUtil$1.run(SourceFile:13)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:709)
        at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:655)
        at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:598)
        at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:258)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:478)
        at java.lang.Thread.run(Unknown Source)
    What am I doing wrong?
  2. jammasterz

    jammasterz New Member

    I downgraded from rhino 1.7R4 to 1.6R7 and now i got a new error instead:
    Code (Text):
    WARNING: [WorldEdit] Failed to execute script
    java.lang.NoSuchMethodError: com.sk89q.worldedit.scripting.RhinoContextFactory.enterContext()Lorg/mozilla/javascript/Context;
        at com.sk89q.worldedit.scripting.RhinoCraftScriptEngine.evaluate(RhinoCraftScriptEngine.java:51)
        at com.sk89q.worldedit.WorldEdit.runScript(WorldEdit.java:761)
        at com.sk89q.worldedit.command.ScriptingCommands.execute(ScriptingCommands.java:78)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.sk89q.worldedit.util.command.parametric.ParametricCallable.call(ParametricCallable.java:243)
        at com.sk89q.worldedit.util.command.SimpleDispatcher.call(SimpleDispatcher.java:125)
        at com.sk89q.worldedit.extension.platform.CommandManager.handleCommand(CommandManager.java:225)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.sk89q.worldedit.util.eventbus.MethodEventHandler.dispatch(MethodEventHandler.java:58)
        at com.sk89q.worldedit.util.eventbus.EventHandler.handleEvent(EventHandler.java:73)
        at com.sk89q.worldedit.util.eventbus.EventBus.dispatch(EventBus.java:187)
        at com.sk89q.worldedit.util.eventbus.EventBus.post(EventBus.java:173)
        at com.sk89q.worldedit.forge.ForgeWorldEdit.onCommandEvent(ForgeWorldEdit.java:141)
        at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_44_ForgeWorldEdit_onCommandEvent_CommandEvent.invoke(.dynamic)
        at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55)
        at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:138)
        at net.minecraft.command.CommandHandler.func_71556_a(CommandHandler.java:52)
        at net.minecraft.network.NetHandlerPlayServer.func_147361_d(NetHandlerPlayServer.java:812)
        at net.minecraft.network.NetHandlerPlayServer.func_147354_a(NetHandlerPlayServer.java:791)
        at net.minecraft.network.play.client.C01PacketChatMessage.func_180757_a(SourceFile:37)
        at net.minecraft.network.play.client.C01PacketChatMessage.func_148833_a(SourceFile:9)
        at net.minecraft.network.PacketThreadUtil$1.run(SourceFile:13)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:709)
        at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:655)
        at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:598)
        at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:258)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:478)
        at java.lang.Thread.run(Unknown Source)
  3. PseudoKnight

    PseudoKnight Well-Known Member

  4. jammasterz

    jammasterz New Member

    Nah, it clearly looks like WorldEdit is calling a method thats not in the rhino engine, its either WorldEdit or rhinos problem.

    And the answer in that post is really not helpful :O
  5. PseudoKnight

    PseudoKnight Well-Known Member

    There is no answer in that post. The guy replied with additional information.