persvr / perstore

CommonJS persistence/object storage based on W3C's object store API.
http://www.persvr.org/
96 stars 20 forks source link

perstore/util/settings.js: cannot find local.json when deploying to Tomcat under RIngoJS #44

Open allencblee opened 11 years ago

allencblee commented 11 years ago

When using ringojs and deploying the war to servlet container like tomcat, the following error appears:

JavaException: java.io.FileNotFoundException: /Applications/springsource/sts-3.1.0.RELEASE/STS.app/Contents/MacOS/local.json (No such file or directory) trying to load local.json, make sure local.json is in your current working directory (perstore/util/settings.js#19) at perstore/util/settings.js:19 at perstore/store/filesystem.js:13 (anonymous) at pintura/media/html.js:5

It's because perstore/util/settings.js assumes that local.json is in the current working directory. However, when using an application server, the work directory is the directory of the app server, not the directory of the war.

neonstalwart commented 11 years ago

when using node, the first statement i have in my index.js (assuming that index.js is the entry point to your application) is process.chdir(__dirname); and i have local.json in that same dir. this lets me start the application from any dir (eg node /some/path/to/index.js) without any issues with paths.

i'm not familiar with ringo and so i'm not sure but it looks like fs.changeWorkingDirectory(module.directory); might do the same thing (http://ringojs.org/api/master/fs/#changeWorkingDirectory and http://ringojs.org/api/master/globals/#module.directory)

does that work for you?