Hello:
I'm working with a Java developer and she tells me that this works:
interpreter.eval("(load "/http://people.kmi.open.ac.uk/ning/atms/decipher-atms-single-file.lisp%5C")");
but this doesn't:
interpreter.eval("(load "/Decipher/codes/decipher-atms-single-file.lisp")");
Any idea about why this would be, and how we can load local code from a WAR web service?
Hi Joe,
On Tue, Jun 4, 2013 at 7:17 PM, Joe Corneli holtzermann17@gmail.com wrote:
Hello:
I'm working with a Java developer and she tells me that this works:
interpreter.eval("(load "/http://people.kmi.open.ac.uk/ning/atms/decipher-atms-single-file.lisp%5C ")");
(Assuming the leading dash in "/http" is a typo, this should indeed work...)
but this doesn't:
interpreter.eval("(load "/Decipher/codes/decipher-atms-single-file.lisp")");
But: this should work as well. Can you tell a bit more about the environment? Is this a Windows environment, ie an environment with multiple filesystem root directories? If not and this is on a *nix-like filesystem, I would not understand why this shouldn't work.
What means "doesn't work"? Does it mean something throws a Java exception? Does it mean the file content doesn't actually get loaded, but you see no errors? Is there a Common Lisp condition being thrown?
Any idea about why this would be, and how we can load local code from a WAR web service?
What I did in the past is pick a class which I know to be included in the JAR/WAR, something like "org.armedbear.lisp.Lisp", take its class and get the URL of the required resource from it like this (taken from src/org/armedbear/lisp/Site.java):
URL url = Lisp.class.getResource("boot.lisp");
HTH,
Erik.
In addition to what Erik said, if I remember correctly, LOAD can take a stream as a parameter too, so if you can obtain a Java InputStream to the resource, you should be fine. I'm thinking about something like the following:
LispObject theLoadFunction = interpreter.eval("#'cl:load"); Stream resourceStream = new Stream(theJavaInputStream); theLoadFunction.execute(resourceStream);
this is from memory and untested, so probably it won't work, but you should get the idea.
Of course, if you use the JSR-223 interface, that is handled for you already, but you're using Interpreter directly, and switching is not without cost, so you'll probably be better off if you follow Erik's suggestion or mine.
Alessio
On Tue, Jun 4, 2013 at 9:57 PM, Erik Huelsmann ehuels@gmail.com wrote:
Hi Joe,
On Tue, Jun 4, 2013 at 7:17 PM, Joe Corneli holtzermann17@gmail.comwrote:
Hello:
I'm working with a Java developer and she tells me that this works:
interpreter.eval("(load "/http://people.kmi.open.ac.uk/ning/atms/decipher-atms-single-file.lisp%5C ")");
(Assuming the leading dash in "/http" is a typo, this should indeed work...)
but this doesn't:
interpreter.eval("(load "/Decipher/codes/decipher-atms-single-file.lisp")");
But: this should work as well. Can you tell a bit more about the environment? Is this a Windows environment, ie an environment with multiple filesystem root directories? If not and this is on a *nix-like filesystem, I would not understand why this shouldn't work.
What means "doesn't work"? Does it mean something throws a Java exception? Does it mean the file content doesn't actually get loaded, but you see no errors? Is there a Common Lisp condition being thrown?
Any idea about why this would be, and how we can load local code from a WAR web service?
What I did in the past is pick a class which I know to be included in the JAR/WAR, something like "org.armedbear.lisp.Lisp", take its class and get the URL of the required resource from it like this (taken from src/org/armedbear/lisp/Site.java):
URL url = Lisp.class.getResource("boot.lisp");
HTH,
Erik.
armedbear-devel@common-lisp.net