Re: Problem with SISCweb update
Nikita <[email protected]> Tue, 11 Sep 2007 11:58:18 +0300
| Newsgroups | gmane.comp.java.sisc.user |
|---|---|
| Message-ID | <[email protected]> |
Hello Alessandro,
Suggested solution to put file:// into begining of the path helped
indeed. Thank you all for your help!
Using (class-path-extension-append! '("WEB-INF/code/")) and
require-extension is not acceptable in my case.
I experienced problems, which I can't recall now, with
class-path-extension-append! on a "production" server side which is
located on shared hosting. So I had to use absolute paths and load.
Since than I use my own loader which automatically compiles modified
source files. I find it quite handy for interactive development because
it helps to eliminate compilation phase as compiled versions of files
are always available and are ready to be deployed on production server.
The loader is attached to this letter in case anyone might be interested
in it.
So, it would be great to use relative paths, but in my case an absolute
path to WEB-INF is needed. Is it possible to somehow get it from SISCweb?
Best regards,
Nikita
>
> Sorry you are having problems. I am unable to try your exact test case
> right now, but I believe the problem you are seeing comes from the way
> the (load) function works in SISC. Specifically, (load) takes the path
> to be a URL relative to the path of the file being executed -- in this
> case the JNDI-addressed servlet parameter. (The "Source Loading"
> section in the SISC manual contains some examples.)
>
> Since the path of the file you are loading is inside the web
> application, you can use something like:
>
> (class-path-extension-append! '("WEB-INF/code/"))
> (require-extension (lib loader))
>
> This also has the advantage of addressing the files in a manner
> relative to the application, whatever its name and location.
>
> You can find more details in the SISCweb manual:
>
> http://siscweb.sourceforge.net/swm/ch02.html#adapter-servlet
>
> Let us know how that works for you, or if you have any questions.
>
> Regards,
> ___
> Alessandro
>
>
>
> On 9/10/07, Nikita <[email protected]> wrote:
>
>> Hello,
>>
>>
>> After updating SISCweb from 0.4 to 0.5 my web-application doesn't want
>> to start.
>>
>> It appears that it can't run code from on-init-sexp servlet parameter
>> and breaks on the first line which is:
>> (load "/home/nikita/myapp/WEB-INF/code/loader.scm").
>>
>> The error I get is:
>> javax.servlet.ServletException: ((java-exception . #<java
>> java.io.FileNotFoundException java.io.FileNotFoundException>) (message .
>> "error opening 'jndi:/home/nikita/myapp/WEB-INF/code/loader.scm'.")
>> (location . load))
>> siscweb.web.SISCAdapterServlet.init(SISCAdapterServlet.java:119)
>> javax.servlet.GenericServlet.init(GenericServlet.java:212)
>> ...
>>
>> I have no idea why it adds "jndi:" in front of path. If this code is
>> executed in REPL then everything is fine.
>>
>> Could anyone suggest something?
>>
>>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Sisc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sisc-users
loader.scm
(text/x-scheme, 2.9 KB)
;; Simple library loader. Loads library if it is not yet loaded
;; (permits cyclic dependencies).
;; Source file is compiled and loaded if there is no compiled
;; one or compiled file is older than the source.
;;
;; Usage:
;; (current-directory "/path_to_code")
;; (load "compile.scm")
;; (import loader)
;; (add-load-path "")
;; (require "a")
;; (require "b")
;; (require "c")
(require-library 'sisc/libs/srfi/srfi-1) ; list
(require-library 'sisc/libs/srfi/srfi-69) ; hash table
(module loader
(require add-load-path reset)
(import srfi-1)
(import srfi-69)
(import libraries)
(import file-manipulation)
(define compile-enabled #t)
(define paths '())
(define cache (make-hash-table 'equal))
(define (add-load-path path)
(set! paths
(cons (normalize-url (current-url) path)
paths)))
(define (reset)
(set! cache (make-hash-table 'equal)))
(define (uptodate? name time-modified)
(let ((time (hash-table-ref cache
name
(lambda () #f))))
(and time
(>= time time-modified))))
(define (set-cache name time-modified)
(hash-table-set! cache
name
time-modified))
(define (find-files name ext)
(filter file-exists?
(map (lambda (path)
(string-append path "/" name "." ext))
paths)))
(define (require name)
(if (symbol? name)
(require (symbol->string name))
(let ((source-files (find-files name "scm")))
(if (not (null? source-files))
(let ((source-file (car source-files)))
(if (not (uptodate? name (file-last-modified source-file)))
(begin
(set-cache name (file-last-modified source-file))
(compile-and-load source-file))))
(let ((compiled-files (find-files name "scc")))
(if (not (null? compiled-files))
(let ((compiled-file (car compiled-files)))
(if (not (uptodate? name (file-last-modified compiled-file)))
(begin
(set-cache name (file-last-modified compiled-file))
(load compiled-file))))))))))
(define (compile-and-load src-name)
(let ((compiled-name (string-append (substring src-name
0
(- (string-length src-name) 1))
"c")))
(if (and (file-exists? compiled-name)
(or (not (file-exists? src-name))
(> (file-last-modified compiled-name)
(file-last-modified src-name))))
(load compiled-name)
(compile-file src-name compiled-name))))
)