Open radaczynski opened 11 years ago
This sounds like something you'd only want when deploying to legacy containers, e.g. with using a war file. That means it should be part of lein-ring's war generation.
Well, no :-). When using a war file the jndi lookups are handled by the container and you need to set the container up so that it does the lookups. This can be done either based on the web.xml or container-specific configuration (for instance in case of Tomcat it can be specified in context.xml). That works fine - I have specified a custom web.xml file and when deploy the war file to tomcat, the lookups do work.
The issue is that the lookups don't work when starting jetty via lein ring server. As far as I can tell, jetty needs some special setup in order to support the lookups; http://docs.codehaus.org/display/JETTY/JNDI. This is also what is being done in lein-jetty: https://github.com/mefesto/lein-jetty/blob/master/src/leiningen/jetty.clj.
Why do you need JNDI lookup when using the development server?
I want to have some configuration parameters externalized to web.xml, but I would like to use that configuration in the development mode as well. JNDI seems like the easiest solution to externalize this. Do you have a better idea for externalizing configuration parameters?
Well, ideally there'd be a generic interface for configuration parameters that could be populated from a number of sources. With legacy deployment systems like war files, something like JNDI could be used, while Ring adapters could pull their configuration from environment variables.
Adding JNDI directly to ring-server would tie the library too tightly to Java web libraries. I'd like to stick to the adapter interface where possible.
You have discussed this (a while back) here: https://groups.google.com/forum/?fromgroups=#!topic/clojure-web-dev/dhvYuG97CZk, right? But noone has implemented anything yet, right?
As a result of that conversation, I implemented environ which pulls data from environment variables, values in the project.clj file, and from Java system properties.
It doesn't support JNDI, but I'm considering extending it, maybe making the env
map dynamic so that it can be updated via a binding.
I would really like to be able to use jdni lookups (for env-entries and resources such as datasources), similarly to what lein-jetty offers (https://github.com/mefesto/lein-jetty/blob/master/src/leiningen/jetty.clj). I am not sure whether it belongs here, or lein-ring or both.