2012-04-16 35 views
1

問題中的」文件「實際上是一個Ajax調用,每個ajax調用在特定文件中幾乎發生一個錯誤我們使用有固定裝置打開,但此後然後取出他們JMVC:steal/buildjs - Build is throwing error「無法打開文件文件:/ profile/getPolicy

錯誤:。

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({ 
     url:"/profile/getProfile", 
     type:"get", 
     success:function(data){ 
      try{ 
       STATE.PROFILE = JSON.parse(data); 
      }catch(err){ 
       STATE.PROFILE = data; 
      } 
      updateState(); 
     } 
    }); 

有沒有人有任何想法,當我們嘗試構建時,爲什麼我們會收到這些錯誤?這段代碼在瀏覽器中運行良好!

回答

0

Brian,畢竟你是正確的,因爲刪除Ajax調用確實會從構建中刪除錯誤。儘管措辭已經改變。我們的一個開發者找到了「steal.isRhino」的提及以下頁面: http://javascriptmvc.com/docs.html#!migrate

所以每封裝ajax調用與if語句不工作:

if(!steal.isRhino) { 
    } 

但是,這種跨越是不可行應用。 幸運的是,我們的開發者之一沒有找到合適的解決方案:

所有的Ajax調用必須有一個完整的URL: http://localhost:3000/profile/getProfile - 不只是 - /資料/ getProfile

+0

酷。在部署網站和根網址(假定)發生更改時,您將如何處理此問題? – 2012-04-18 20:45:39

+0

這是一個很好的問題。對我們來說幸運的是,我們正在部署一個完全可以控制的環境。所以這不會是一個問題。儘管我可以看到在其他情況下可能會令人頭疼。所以在那個時候,我們可能會在主配置文件中定義主機變量。 – 2012-04-18 21:32:00