envjs / env-js

A pure-JavaScript browser environment.
http://www.envjs.com/
87 stars 19 forks source link

1.3 pre03 not working in Eclipse/JSDT due to path issue. #32

Open cardinal27513 opened 12 years ago

cardinal27513 commented 12 years ago

I’m trying JavaScript Development Tool and it comes with Rhino as debugging tool. It is very nice.

I was able to make envjs-1.2.13 working. Now, switching to the 1.3 pre03. Hitting issue on path setting.. Under envjs/rhino.js, at the end it calls require to load in additional modules. require('envjs/platform/rhino'); require('envjs/window'); But inside require, it relies on the “user.dir” to search for file and it fail for my case since, user.dir will return the directory where Eclipse is started from. var currentPath = java.lang.System.getProperty('user.dir');

Should it goes with the way to have an envjsConfig object with baseUrl property set prior to load Envjs? Then, internally, use the object to load file accordingly.

I did a simple hack & get all the files loaded but I’m still seeing weird things (newbie to java & javascript) Somewhere the file path are messed up...

org.mozilla.javascript.WrappedException: Wrapped java.net.URISyntaxException: Illegal character in path at index 10: file://C/:\Eclipse-indigo/C:\workspace\client\scripts\example\simple.js (file:/C:/workspace/client/scripts/envjs/platform/rhino.js#251) at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1773) at org.mozilla.javascript.MemberBox.newInstance(MemberBox.java:202) at org.mozilla.javascript.NativeJavaClass.constructSpecific(NativeJavaClass.java:281) at org.mozilla.javascript.NativeJavaClass.construct(NativeJavaClass.java:200) at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3377) at script(file:/C:/workspace/client/scripts/envjs/platform/rhino.js:251) at script(file:/C:/workspace/client/scripts/envjs/platform/core.js:1021) at script(file:/C:/workspace/client/scripts/envjs/platform/core.js:2403) at script(file:/C:/workspace/client/scripts/envjs/platform/core.js:1007) at script(file:/C:/workspace/client/scripts/envjs/platform/core.js:943) at script(file:/C:/workspace/client/scripts/envjs/window.js:855) at script(file:/C:/workspace/client/scripts/envjs/window.js:34) at script.require(/C:/workspace/client/scripts/envjs/rhino.js:85) at script(/C:/workspace/client/scripts/envjs/rhino.js:108) at script(/C:/workspace/client/scripts/envjs/rhino.js:105) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2487) at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:178) at org.mozilla.javascript.tools.shell.Main.evaluateScript(Main.java:564) at org.mozilla.javascript.tools.shell.Main.processFileSecure(Main.java:486) at org.mozilla.javascript.tools.shell.Main.processFile(Main.java:452) at org.mozilla.javascript.tools.shell.Global.load(Global.java:244) 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.MemberBox.invoke(MemberBox.java:161) at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:413) at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3330) 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.exec(InterpretedFunction.java:175) at org.mozilla.javascript.tools.shell.Main.evaluateScript(Main.java:564) at org.mozilla.javascript.tools.shell.Main.processFileSecure(Main.java:486) at org.mozilla.javascript.tools.shell.Main.processFile(Main.java:452) at org.eclipse.wst.jsdt.debug.rhino.debugger.shell.DebugMain$Evaluator.run(DebugMain.java:89) at org.mozilla.javascript.Context.call(Context.java:515) at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:507) at org.eclipse.wst.jsdt.debug.rhino.debugger.shell.DebugMain.main(DebugMain.java:218) Caused by: java.net.URISyntaxException: Illegal character in path at index 10: file://C/:\Eclipse-indigo/C:\workspace\client\scripts\example\simple.js at java.net.URI$Parser.fail(Unknown Source) at java.net.URI$Parser.checkChars(Unknown Source) at java.net.URI$Parser.parseHierarchical(Unknown Source) at java.net.URI$Parser.parse(Unknown Source) at java.net.URI.(Unknown Source) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.mozilla.javascript.MemberBox.newInstance(MemberBox.java:194) ... 28 more

chrisnash commented 12 years ago

I ran into the same issue with the incorrectly-formatted "file:" URL, and looked around to find a fix in a pull request from about a year ago from moschel ( https://github.com/thatcher/env-js/pull/23 ). I found a similar problem though following that when trying to load local resources under Rhino; anyway the three commits on my branch https://github.com/chrisnash/env-js/commits/onwindows should address these.

A status update on this project would be nice...