Dan thank you for your help. The first snippet worked greately.

Marco

> -----Original Message-----
> From: Dan Tran [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, March 30, 2003 3:38 AM
> To: Struts Users Mailing List
> Subject: Re: Setting externally JNDI properties
> 
> 
> The following snippets may help
> 
> <snippet>
>       //place your jndi under your WEB-INF/classes
>       ClassLoader classLoader = getClass().getClassLoader();
>       InputStream in = 
> classLoader.getResourceAsStream("jndi.properties");
>       if ( in == null )
>           throw new MissingResourceException("JNDI property 
> file jndi.properties' not found in classpath.",
>                                              null, null);
> 
>       Properties jndiProperties = new Properties();
>       try {
>         jnidProperties.load(in);
>       }catch ( IOException e ) {
>         throw new MissingResourceException("Problem loading 
> 'jndi.properties'", null, null);
>       }
> </snippet>
> 
> Or
> 
> <snippet>
>       //place your jndi file under WEB-INF
>      InputStream is = 
> servlet.getServletContext().getResourceAsStream("/WEB-INF/jndi
.properties");
>      if ( in == null )
>           throw new MissingResourceException("jndi property 
> file jndi.properties' not found in classpath.",
>                                              null, null);
> 
>       Properties jndiProperties = new Properties();
>       try {
>         jndiProperties.load(in);
>       }catch ( IOException e ) {
>         throw new MissingResourceException("Problem loading 
> 'jndi.properties'", null, null);
>       }
> </snippet>
> 
> Good luck.
> 
> -D
> ----- Original Message -----
> From: "Marco Tedone" <[EMAIL PROTECTED]>
> To: "Struts-user-list " <[EMAIL PROTECTED]>
> Sent: Saturday, March 29, 2003 2:12 PM
> Subject: Setting externally JNDI properties
> 
> 
> > Hi,
> >
> > At present my application is 'talking' with Jboss via specific 
> > properties set a compile time. I would like to move those 
> properties 
> > in a jndi.properties file (which I would put under 
> WEB-INF/classes). 
> > How could
> I
> > retrieve jndi.properties without specifying the exact 
> location (which
> could
> > vary from user by user), i.e. dynamically? I tried with the 
> following:
> >
> > 
> getServlet().getServletContext().getResource("jndi.properties"); but 
> > the return is null.
> >
> > I also tried
> >
> > 
> getServlet().getServletContext().getResource("/jndi.properties") but 
> > the return was the same.
> >
> > I also tried to put jndi.properties in the jar file containing the 
> > application's classes but nothing.
> >
> > Any idea?
> >
> > Thanks,
> >
> > Marco
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to