• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to replace a property file with JNDI ?

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 :

reply
    Bookmark Topic Watch Topic
  • New Topic