JMVC:steal / buildjs - Build抛出错误“无法打开文件文件:/ profile / getPolicy

时间:2012-04-16 17:09:56

标签: javascript jquery javascriptmvc

有问题的“文件”实际上是一个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();
        }
    });

有没有人知道我们在尝试构建时遇到这些错误的原因?这段代码在浏览器中运行良好!

1 个答案:

答案 0 :(得分:0)

Brian,毕竟你是对的,因为删除Ajax调用确实会从构建中删除错误。虽然措辞有所改变。我们的一位开发人员发现在下一页提到“steal.isRhino”: http://javascriptmvc.com/docs.html#!migrate

所以使用if语句封装每个ajax调用都可以工作:

  if(!steal.isRhino) {
  }

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

所有ajax调用必须具有完整的URL: http://localhost:3000/profile/getProfile - 不仅仅是 - / profile / getProfile