Re: How to locate external configuration file
From: Alexander Kienzle (nospam_at_nomail.com)
Date: 07/21/04
- Next message: Stewart Gordon: "Re: save data to server's local disc?"
- Previous message: Georg Andersson: "save data to server's local disc?"
- In reply to: Merrill: "Re: How to locate external configuration file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 21 Jul 2004 15:29:27 +0200
Hi Merril
Thanks for the answer, but how do I find that directory?
I assume I cannot use getResourceAsStream in those cases but I'm not
sure because the ClassLoader's getResourceAsStream method will
look in many places (the order which directories are searched is not
described in my Java docs!).
Using System.GetProperties("catalina.home") + "shared/..." would not
work if the application server is websphere (and vice versa).
Could I just try 'catalina.home' and if it fails, assume that the
application server is websphere and use the websphere's
system property to get to the path or is there a more generic way
to find the actual application server?
I also have another problem, that is, when I have multiple versions of
my package (using different context-path). They would most probably
require different configuration files. Is it possible to put the
configuration
file in the same directory as the .jar file? Will getResourceAsStream
work then? If not, how can I find out in which directory the .jar file is
(maybe ServletContext.getRealPath("/"))?
Thanks in advance
Alex
"Merrill" <mhigginson1@socal.rr.com> wrote in message
news:gZ9Lc.42935$SO5.27485@twister.socal.rr.com...
> Alex,
>
> Every Appserver has some sort of common area where all applications
> installed on the app server can look for classes common to all
applications.
> In Tomcat it's shared/classes. In WebSphere it's
> WebSphere/Appserver/lib/ext, or configurable as a classpath variable in
the
> admin console. It sounds like putting your XML file in one of these
common
> areas would be the least amount of work for an installer.
>
> Merrill
>
> "Alexander Kienzle" <nospam@nomail.com> wrote in message
> news:cditht$qi7$1@atlas.ip-plus.net...
> > I'm new to Java programming. I'm developing a Servlet for tomcat which
> needs
> > an external configuration file. With external I mean a file (in XML
> format)
> > which
> > is customizable and not contained in my package. I don't want to
hardcode
> > any
> > path and I would like to be independent of the application server
(tomcat,
> > websphere,...).
> > Until now, I put the file in my package and open it using
> > obj.getClass.getResourceAsStream
> > but when I put my whole package in a .jar file, it prevents that the
file
> is
> > customizable
> > (or the .jar file would have to be unpacked on each installation).
> > Putting any path in the web.xml has the same problem.
> > The article @ javaworld
> > (http://www.javaworld.com/javaworld/jw-04-1999/jw-04-cooltools.html)
> > didn't help because the JDBC connection string actually belongs into the
> > configuration file.
> > Also defining a system property when starting tomcat (-Dparam=value) is
> not
> > a very good
> > option as it complicates work for the IT manager (already complicate
with
> > JAAS,
> > required changes in tomcat's catalina.policy,...).
> > Someone got any experience how to easily configure a servlet, keep the
> > configuration
> > customizable (the configuration itself as well as the location of the
> > configuration file) and
> > how to locate the configuration file in a file-system- and
> > application-server-independent way?
> >
> > Many thanks
> > Alex
> >
> >
>
>
- Next message: Stewart Gordon: "Re: save data to server's local disc?"
- Previous message: Georg Andersson: "save data to server's local disc?"
- In reply to: Merrill: "Re: How to locate external configuration file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|