Symlinks and Javascript Files

87 views
Skip to first unread message

Peter Robinett

unread,
Aug 13, 2009, 9:57:33 PM8/13/09
to Lift
My Lift project is in a git repository and to the repository I've
added a submodule. Since right now I only want one javascript file
from this submodule, my thought was to make the directory src/main/
webroot/js and then make a symbolic link to the javascript file in
question. Unfortunately, when I try to request the file at
http://localhost:9090/js/jquery.sparkline.js, I get a 403 response
that says the page is not defined in my sitemap. There was no note of
the request in the stdout.

Thinking that the js subdirectory is the problem, I then tried making
the symlink in the webroot directory and got a 404 error. On stdout it
said:
2009-08-13 18:38:23.051::WARN: Aliased resource: file:/Users/peter/
Sites/Equal%20Networks/server/src/main/webapp/
jquery.sparkline.js==file:/Users/peter/Sites/Equal%20Networks/server/
vendors/dashboard/www/jquery.sparkline.js

From this I gather than Lift is troubled by the presence of a symlink
and refused to acknowledge its presence. Is this true? If so, why?

From the thread last week on ExtJS I see a discussion on loading files
in webroot, including supporting a css directory by adding the
following to Boot.scala:
ResourceServer.allow {
case "css" :: _ => true
}

I already have a css file being served from a directory in the exact
same location without any additions to Boot.scala. Nonetheless, I
tried the following:
ResourceServer.allow {
case "js" :: _ => true
}

Unfortunately, this had no effect. So, how can I get my symlinked
javascript to be server? Or should I just give up on symlinks
altogether (I'm not a git master, so perhaps that was the wrong
approach anyway).

Peter Robinett

PS I'm on 1.1-SNAPSHOT.
PPS The YUI Compressor works well. Very cool.

Derek Chen-Becker

unread,
Aug 14, 2009, 9:43:35 AM8/14/09
to lif...@googlegroups.com
Is the path to that file defined in your SiteMap?  In the case of using ResourceServer, the "js" that you've tried means that the script should be under a "js" subdir.

Derek

Peter Robinett

unread,
Aug 14, 2009, 3:28:51 PM8/14/09
to Lift
It is not in my site map. I did try the ResourceServer with the
symlinked script in the 'js' subdir.

Peter

Derek Chen-Becker

unread,
Aug 16, 2009, 10:13:57 AM8/16/09
to lif...@googlegroups.com
OK, this is not Lift's error message, but rather Jetty's. You need to set the following property to tell Jetty not to check symlinks:

-Dorg.mortbay.util.FileResource.checkAliases=False

Derek

Peter Robinett

unread,
Aug 17, 2009, 9:09:20 PM8/17/09
to Lift
mvn -Dorg.mortbay.util.FileResource.checkAliases=False jetty:run lead
to:

HTTP ERROR 503

Problem accessing /jquery.sparkline.js. Reason:

java.lang.IllegalStateException: Alias checking disabled

Is is just for the symlin in the webroot – requsting the one in the js
subdirectory still causes Lift to say it isn't in the SiteMap.

Any ideas? Thanks?

Peter

Derek Chen-Becker

unread,
Aug 18, 2009, 10:14:35 AM8/18/09
to lif...@googlegroups.com
I really don't know enough about Jetty to really say what else is going wrong here, Sorry :(

Derek

David Pollak

unread,
Aug 18, 2009, 1:39:32 PM8/18/09
to lif...@googlegroups.com
I'd advise against using sym links.  They don't work on Windows and don't necessarily get JARed/WARed up correctly.
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp
Reply all
Reply to author
Forward
0 new messages