• 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

keeping properties file out of war

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We've got a Seam app doing all the usual things with datasources. Notably, pulling datasource info (url, username, password, etc.) from a separate property file.

Is there a way to store and source .properties file outside of the .war? If I've got this right, Seam assumes the "root" of the paths used are the root of the .war?

But that's a bummer since installing on a new server (with a different database) means have to explode the .war just to edit the datasource-config file.

How do you guys handle this situation? Or do you just live with having to explode the .war to make config edits?

Thanks!

Angelo Mario
 
Ranch Hand
Posts: 433
Netbeans IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having different Maven-profiles with different configurations for different environments.
So, if you are using Maven as your build-tool, have a look at http://maven.apache.org/guides/introduction/introduction-to-profiles.html
 
Angelo Mario Del Grosso
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,

Is not a build problem, but after it was made! I have to read several configuration values from a file keeping out of war! It is possible?

I'm not using maven!

other suggestions?

Joachim Rohde wrote:I'm having different Maven-profiles with different configurations for different environments.
So, if you are using Maven as your build-tool, have a look at http://maven.apache.org/guides/introduction/introduction-to-profiles.html

 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Angelo,

i know the problem you're talking about exactly I'm still not sure what would be the best way to externalize such configuration properties completely to be able to deploy the same WAR file on any server without having to modify the content of the WAR itself.

I guess one clean way would be to use a JNDI lookup inside your application in order to retrieve database configuration parameters etc. Every application server or servlet container offers a way to provide information via JNDI lookups to applications running inside of it.

So you could always use the same JNDI lookup key (e.g. "jdbc/yourDatabase") inside your application and configure the container/server to provide the correct information via this key. This way you don't have to modify the application itself but instead you use the application server facilities to configure which information should be provided via this lookup key. This should be enough for typical use cases I think. For example if you have an application server for testing you usually want to use a test database together with it. From your application's view this doesn't make any difference because the JNDI key would be the same. All that you or an administrator would have to do is to configure the application server to provide configuration parameters for the correct database etc.

I hope this was more or less clear

But I'm sure there are other ways to configure a web application without having to modify the application itself. Even though Maven profiles would be a solution to easily build different WARs I'd still be interested to hear about other ideas.

Marco
 
Angelo Mario Del Grosso
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Angelo,

i know the problem you're talking about exactly I'm still not sure what would be the best way to externalize such configuration properties completely to be able to deploy the same WAR file on any server without having to modify the content of the WAR itself.

I guess one clean way would be to use a JNDI lookup inside your application in order to retrieve database configuration parameters etc. Every application server or servlet container offers a way to provide information via JNDI lookups to applications running inside of it.

So you could always use the same JNDI lookup key (e.g. "jdbc/yourDatabase") inside your application and configure the container/server to provide the correct information via this key. This way you don't have to modify the application itself but instead you use the application server facilities to configure which information should be provided via this lookup key. This should be enough for typical use cases I think. For example if you have an application server for testing you usually want to use a test database together with it. From your application's view this doesn't make any difference because the JNDI key would be the same. All that you or an administrator would have to do is to configure the application server to provide configuration parameters for the correct database etc.

Marco Ehrentreich wrote:
I hope this was more or less clear

But I'm sure there are other ways to configure a web application without having to modify the application itself. Even though Maven profiles would be a solution to easily build different WARs I'd still be interested to hear about other ideas.

Marco



Thanks a lot, Marco!

I have seen the JNDI solution! And i think is one of the best! But i develop in seam and i'm looking for something more integrated system. I.E. if I put my .property file in my deploy directory, how i have to modify my code to read the values and replace them in a correct configuration? Several libraries manage the initialization and the resorceBundle! Can i use it to solve my matters?

Have you some code that i can read? Also with the solution that you proposed me!

Thanks

Angelo Mario
 
reply
    Bookmark Topic Watch Topic
  • New Topic