• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

How can I save my config files?  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, folks!
I use JBoss AS 7 and Struts 2. My problem is I need to save config file(database settings) on the disk, like a simple myconfig.xml or something like this. One of the most big problems, that I have .war file and cannot to save inside /WEB-INF(hah, but I think it'd be good solution). Of course, I don't want, that somebody will be able to read my config from network, only for local usage. Just imagine, you go to http://yourhost//install.action, then you fill out your database settings(username,password,host,port), my install.java(action class in struts.xml) and then it generates databaseSettings.xml and it need to retain somewhere. And the place shouldn't be available from network.

If I use tomcat without .war or .ear files, I can do it easy:
write:(code in servlet or in my case, in POJO class of struts2 action)


read:


What can I do? I wanna use .war, but I need to use config files. Where can I retain my configs in JBoss AS 7?
 
Bartender
Posts: 20725
124
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most of my database setting are done to set up a database connection pool, and that's something that's part of the webapp server, not of the webapp, so I just configure the pool and there's nothing that would or could go into or be accessed by the WAR.

One or 2 specialized apps do need stuff like that, and of course, there's lots of other config data besides databases that it's useful not to have packaged inside the war. So I normally put that in a file, which can be a java properties file, JSON, XML, or whatever.

Because I'm used to environments where I develop on Windows and run production on Solaris or Linux and I have a firm policy of one WAR for all instances, I don't hard-code the location of my config files in the WAR, however. I use web.xml config parameters that are backed by the server's JNDI directory and do a JNDI lookup to get the path of the file to open and read.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!