1

有问题的“文件”实际上是一个 Ajax 调用。对于特定文件中的每个 ajax 调用,我们几乎都会遇到一个错误。我们过去常常打开固定装置,但从那以后就将它们移除了。

错误:

failed to open file  file:/profile/getPolicy   JavaException: java.io.FileNotFoundException: /profile/getPolicy (No such file or directory) 
Exception in thread "Thread-2" org.mozilla.javascript.EcmaError: TypeError: Cannot call method "indexOf" of null (steal/rhino/env.js#24532)
    at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3654)
    at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3632)
    at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3660)
    at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3679)
    at org.mozilla.javascript.ScriptRuntime.undefCallError(ScriptRuntime.java:3698)
    at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2221)
    at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2214)
    at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3143)
    at script(steal/rhino/env.js:24532)
    at script(steal/rhino/env.js:2278)
    at script.makeRequest(steal/rhino/env.js:24484)
    at script(steal/rhino/env.js:2027)
    at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2487)
    at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
    at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398)
    at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065)
    at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
    at org.mozilla.javascript.Synchronizer.call(Synchronizer.java:79)
    at org.mozilla.javascript.tools.shell.Runner.run(Global.java:1162)
    at org.mozilla.javascript.Context.call(Context.java:515)
    at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:507)
    at org.mozilla.javascript.tools.shell.Runner.run(Global.java:1156)
    at java.lang.Thread.run(Thread.java:662)
could not load script  http://localhost:3000/socket.io/1/?t=1334594888337&jsonp=0  
  TypeError: Cannot find function 0.0. 
!!!!!!!!!!! ERROR !!!!!!!!!!!

-message    = Cannot find function 0.0.
-fileName   = http://localhost:3000/socket.io/1/?t=1334594888337&jsonp=0
-name       = TypeError
-lineNumber = 0
failed to open file  file:/profile/getProfile   JavaException: java.io.FileNotFoundException: /profile/getProfile (No such file or directory) 
Exception in thread "Thread-4" org.mozilla.javascript.EcmaError: TypeError: Cannot call method "indexOf" of null (steal/rhino/env.js#24532)

如您所见,下一个错误与下一个 ajax 调用有关。我们的 ajax 调用并没有做任何奇怪的事情:

$.ajax({
        url:"/profile/getProfile",
        type:"get",
        success:function(data){
            try{
                STATE.PROFILE = JSON.parse(data);
            }catch(err){
                STATE.PROFILE = data;
            }
            updateState();
        }
    });

有谁知道为什么我们在尝试构建时会遇到这些错误?此代码在浏览器中运行良好!

4

1 回答 1

0

布赖恩,毕竟你是对的,事实上删除 Ajax 调用确实会从构建中删除错误。虽然措辞变了。我们的一位开发人员在以下页面上发现了“steal.isRhino”的提及:http://javascriptmvc.com/docs.html#! migrate

因此,使用 if 语句封装每个 ajax 调用确实有效:

  if(!steal.isRhino) {
  }

但是,这在整个应用程序中是不可行的。 幸运的是,我们的一位开发人员确实找到了正确的解决方案:

所有 ajax 调用必须有一个完整的 url: http://localhost:3000/profile/getProfile - 不只是 - /profile/getProfile

于 2012-04-18T19:16:41.087 回答