1

I'm building a new web app using Spring MVC 4 (under Tomcat) and I need to know what is the best approach to store the message source in my webapp.

Actually, I'm thinking to use the Spring properties file to manage all labels but I have some questions to ask:

  1. If I add a new message in my properties file, do I need to redeploy my webapp on Tomcat (restart application on Tomcat)?
  2. Could be the database driven resource the best approach for this? In this case, i could avoid to redeploy the webapp on Tomcat (because my message resources are managed in my database)...

Thank you!!

janisz
  • 6,292
  • 4
  • 37
  • 70
user3449772
  • 749
  • 1
  • 14
  • 27
  • 1
    you should have to clean and run your web application,if properties files are used(Using properties files is my option for your case). NB:for that you just need to save your file after some modifications done,tomcat will automatically starts. – Miller Oct 30 '15 at 12:06
  • Thank you! but one thing: when i upload a war with changes on tomcat, tomcat will restarts...in this case, the website will be down for some minutes...it's right? – user3449772 Oct 30 '15 at 12:09
  • 1
    I thought this link will helps you http://stackoverflow.com/questions/6583502/how-do-i-update-a-tomcat-webapp-without-restarting-the-entire-service – Miller Oct 30 '15 at 12:13
  • 1
    http://stackoverflow.com/questions/14972494/how-to-deploy-war-files-to-tomcat-manually – Miller Oct 30 '15 at 12:17

1 Answers1

1

To answer your question yes you will have to redeploy if your messages change. Resource bundles are built and compiled once into the class files and stay the same unless you rebuild and redeploy. If you find that you need a dynamic messages that change without redeploying then it would be best to use something like a database. It's unusual however if you can't bring the application down then yes, put them in a database so you can redeploy them.

Dale
  • 1,613
  • 4
  • 22
  • 42
  • Thanks! :) but are there solutions to update my webapp without shutting down the application? for example: the user is logged on my webapp and I decide to redeploy my application because I changed some messages. So, when I will upload the new war on tomcat, the user will receive a server error during its use...it's right? – user3449772 Oct 30 '15 at 12:54
  • 1
    Maybe I wasn't clear about how I said my solution. Use the database to hold your values so you don't have to reboot. That's what I meant when I said ["it would be best to use something like a database. It's unusual however if you can't bring the application down then yes, put them in a database so you can redeploy them."] in my solution above. So to confirm, a database solution is best. Make sure you aren't using a singleton pattern where the data is only read once. Have the database be read every time so you have the ability to update the values on the fly. – Dale Oct 30 '15 at 13:00