I'm sorry, I'm still struggling with this.  I've changed my
service class to extend AxisServlet and can do the getResourceAsStream, but
it always appears to return a null pointer.  I've tried putting my
properties file in the JAR, and the whole Tomcat tree is positively
littered with copies (to see if the method was looking in some other
directory).  

What I really would like to do is distribute my classes
in a JAR and have the properties file be somewhere else, hopefully
relative to the JAR file.  Here's my class constructor:

  public NCNWebSvc() throws CFException {
    try {
      Properties P = new Properties();
      InputStream Str =
getServletContext().getResourceAsStream("NCNWebSvc.properties");

      P.load(Str);
      passphrase = P.getProperty("Passphrase");
      hostname = P.getProperty("Hostname");
      portnum = P.getProperty("Portnum");
    }
    catch (Exception ex) {
      throw new CFException("Error reading properties file:  " +
ex.getMessage());
    }
  }


I always get this back: Error reading properties file:  null

> -----Original Message-----
> From: Shapira, Yoav [mailto:[EMAIL PROTECTED]
> Sent: Thursday, September 18, 2003 2:53 PM
> To: [EMAIL PROTECTED]; Tomcat Users List
> Subject: RE: Where should I put properties files
> 
> 
> 
> Howdy,
> 
> >I hate to be totally ignorant, but I can't seem to discover how my
> >web service class gets access to ServletContext.  I'm sure there's
> >some static method in Axis that I can call, but I've just 
> been rooting
> >around in the source for about two hours, to no avail.
> 
> It depends what your web service class is.  If you are extending
> AxisServlet or AxisServletBase, just call getServletContext() 
> is that's
> available from the HttpServlet parent class.
> 
> Another approach is to use a ServletContextListener which 
> populates some
> singleton bean with the properties, and then have your service class
> access this singleton bean.  The advantage here is that your service
> class doesn't have to worry about how the bean is populated.
> 
> Yoav Shapira
> 
> 
> 
> This e-mail, including any attachments, is a confidential 
> business communication, and may contain information that is 
> confidential, proprietary and/or privileged.  This e-mail is 
> intended only for the individual(s) to whom it is addressed, 
> and may not be saved, copied, printed, disclosed or used by 
> anyone else.  If you are not the(an) intended recipient, 
> please immediately delete this e-mail from your computer 
> system and notify the sender.  Thank you.
> 

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

Reply via email to