aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes How to replace a property file with JNDI ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to replace a property file with JNDI ?" Watch "How to replace a property file with JNDI ?" New topic
Author

How to replace a property file with JNDI ?

Leinad Nongag
Greenhorn

Joined: Aug 25, 2009
Posts: 18
Hello everybody,

I'm building a java web application that will be in the future deployed in multiple environment. And to simplify the deployment, I would like to use container-base properties without having to edit the property files for each environment. So far, I have only 6 properties that might change depending on the environment.

I've seen many examples that seemed very complex for what I must do. I don't want to mix the JARs in my WAR with those from the container. I just want something that is as simple as loading a property file in the container that will be available to use in the WAR.

I'm really new to JNDI, thought I used them in the past, not knowing how to create one.

Can someone direct me to a simple example ? Something really basic.

Thank you !
Leinad Nongag
Greenhorn

Joined: Aug 25, 2009
Posts: 18
Hi,

I'm still searching the web and I found something that looks interesting.



I want to do something like that, define the server connection as a global property from the server.xml and use it in the context.xml . I would like to mix both since I'm using Spring in my webapp. I want to set the database connection info and to add other properties.

Can I add any more properties there and how do I apply them into our files ?

Leinad Nongag
Greenhorn

Joined: Aug 25, 2009
Posts: 18
So I was able to making work the previous example, now, I only have to pass a single string parameter from the server to the application.

Something like

<env-entry>

But I have yet to provide the link between the two configs.

I'll continie to search the web.
Leinad Nongag
Greenhorn

Joined: Aug 25, 2009
Posts: 18
Well I found a way to resolve my problem and I created a custom property loader. So, now I can add as many properties I want that way :


Both files goes into a jar that is both refrence by the tomcat server and the web application





Into the web app web.xml


Into the server's context.xml


Everything is working fine with that.


When you need to read the value you do like this :

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to replace a property file with JNDI ?