javascript - JMVC : steal/buildjs - Build is throwing error "failed to open file file:/profile/getPolicy

标签 javascript jquery javascriptmvc

所讨论的"file"实际上是一个 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();
        }
    });

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

最佳答案

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

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

  if(!steal.isRhino) {
  }

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

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

关于javascript - JMVC : steal/buildjs - Build is throwing error "failed to open file file:/profile/getPolicy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10178535/

相关文章:

javascript - 新的 XMLHttpRequest 无法在 Firefox 上运行

javascript - 如何使用 typescript 将参数传递给 addEventListener 监听器函数?

javascript - div 标签内的 if 条件

javascript - 使用jQuery将span内容替换为字段值

javascript - 我的数据库数据未显示在 jQuery 数据表中

php - 如何在 PHP 中回显这个 jQuery

javascript - 具有动态路由的 Angular $http.get?

javascript - 在 foreach 循环中调用 JavaScript 函数

javascript - 在 JavasciptMVC 中存储常量值的最佳方法是什么

javascript - 将 Selenium-IDE 与丰富的 Javascript 应用程序一起使用?