On Fri, Aug 29, 2003 at 02:02:23PM +0200, Milen Dyankov wrote:
> Hi,
>
> suppose I have EJB that needs to read some configuration data from external
> file (lets say an XML file).
> Where I'm supposed to place this config file, and how can I tell my EJB
> where it is?
>
> I've tried to pack both the EJB and "config.xml" in jar and use something
> like
>
> File file = new File("config.xml");
>
> but it looks like my EJB is expecting to find "config.xml" in
> "/path/to/jboss/bin" folder.
>
Filesystem access from an EJB is not recommended according to the
specification. But - if you have packaged the config.xml in a jar, and
the jar is on the classpath, use the following construct:
InputStream in =
Thread.currentThread().getContextClassLoader().getResourceAsStream("config.xml");
then read from the InputStream.
//Anders
--
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. Anders Engstr�m [EMAIL PROTECTED]
. http://www.gnejs.net PGP-Key: ED010E7F
. [Your mind is like an umbrella. It doesn't work unless you open it.]
pgp00000.pgp
Description: PGP signature
