• 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 can I save my config files?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic