Results 1 to 10 of 10

Thread: Configuration / Deployment question

  1. #1

    Default Configuration / Deployment question

    Hi,

    We're running into a problem with Spring and configuration when deploying our war file and needing to customize some of the properties within it.

    For example, we need to set an ip address for one of our classes that Spring initializes which will be different in each customer's situation. Loading the applicationContext.xml during startup will throw lots of errors if this is not set correctly, but it's difficult to update the properties in the war before deployment. Obviously as a web app, putting the properites outside of the war is not an option.

    I would have thought this is a fairly common problem, and was wondering how people deal with it?

    cheers,

    David

  2. #2
    Join Date
    Aug 2004
    Posts
    107

    Default

    Search for PropertyPlaceholderConfigurer in the forums.

    Check out samples/jpetstore/war/WEB-INF/applicationContext.xml.

    It basically injects variables defined in the xml files with values from the properties file.

    Dino

  3. #3
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    I haven't dealt with this problem myself. But it doesn't seem to be wrong to add a property file outside of the WAR file. Just put it somewhere on the classpath and have a PropertyPlaceholderConfigurer load it.

  4. #4

    Default

    Ummm...not sure you understood my post.

    My problem is how to change the properties in the properties file in the war BEFORE deployment.

    cheers,

    David

  5. #5

    Default

    My first reply was to hucmuch.

    wpoitras - where would you put it outside the war file? The war IS the web application. Putting it outside would mean putting it outside the web application, which can't be right, and would present problems even getting access to it.

    cheers,

    David

  6. #6
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    Quote Originally Posted by hay7777
    where would you put it outside the war file? The war IS the web application. Putting it outside would mean putting it outside the web application, which can't be right, and would present problems even getting access to it.
    You could put anywhere. As long as your servlet container startup added that directory to the classpath, I believe the war file would be able to pick up the property file. I guess it depends how much control you have over startup and deployment.

  7. #7

    Default

    Hi,

    Yeah, we could.

    It just seems ugly to me, and breaks the encapsulation of the webapp.

    cheers,

    David

  8. #8
    Join Date
    Aug 2004
    Posts
    107

    Default

    You can extend PropertyPlaceholderConfigurer to read the properties from the database.

    Check http://spring-config.sourceforge.net for approaches on configuring properties.

    BTW: the way I have dealt with it in the past is to have the properties outside the war file. You have to in certain circumstances because you may want to modify the properties at run-time and packaging properties as part of the war file won't allow for this.

    Dino

  9. #9
    Join Date
    Sep 2004
    Location
    Melbourne, Australia
    Posts
    54

    Default

    If you are just looking at configuring one value spring-config/extending PropertyPlaceholderConfigurer might be a bit much. I wrote spring-config to solve http://forum.springframework.org/showthread.php?t=15674 kind of problem.

    Have a look at spring's ServletContextPropertyPlaceholderConfigurer class. It allows you to configure beans using web.xml context-params and properties files.

    Cheers,
    Dan
    Last edited by robyn; May 16th, 2006 at 04:01 AM.

  10. #10

    Default

    Hi,

    Isn't this a job for Ant?

    I need different settings for different environments so I have Ant set up to select the appropriate property file and place into the war (in the classes directory where Spring can get at it).

    Cheers

    Rakesh

Similar Threads

  1. configuration question
    By lumpynose in forum Container
    Replies: 7
    Last Post: Aug 31st, 2005, 07:56 PM
  2. Replies: 4
    Last Post: Aug 8th, 2005, 05:20 PM
  3. Replies: 2
    Last Post: Jul 14th, 2005, 03:56 AM
  4. Deployment configuration options
    By Patrick Bourke in forum Architecture
    Replies: 2
    Last Post: Jun 9th, 2005, 01:15 PM
  5. Replies: 4
    Last Post: Oct 12th, 2004, 06:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •