RE: Where should I put properties files

2003-09-19 Thread Michael D. Spence
> -Original Message-
> From: Shapira, Yoav [mailto:[EMAIL PROTECTED]
> Sent: Friday, September 19, 2003 9:14 AM
> To: [EMAIL PROTECTED]
> Subject: RE: Where should I put properties files
>
>
>
> Don't do this in the constructor of your servlet, as it's not
> initialized yet.  Do it in the init method (after calling
> super.init) or
> later.
>
> Put just one copy of your properties file in the WEB-INF directory of
> your webapp.  Then do
>
> Properties p = new Properties();
> InputStream is =
> getServletContext().getResourceAsStream("/WEB-INF/NCNWebSvc.pr
> operties")
> ;
> p.load(is);
>

Ok, that makes sense.  I changed it to this:

public class NCNWebSvc  extends AxisServletBase {
  public NCNWebSvc() {
  }

  public String NoOperation(String xxx) {
log.info("In noop" + xxx);
return "noop was called successfully with arg " + xxx;
  }

public void init() {
  log.info("Calling super.init");
  super.init();
  try {
log.info("getResourceAsStream");
InputStream Str = getServletContext().getResourceAsStream(
"/WEB-INF/NCNWebSvc.properties");
Properties P = new Properties();
P.load(Str);
passphrase = P.getProperty("Passphrase");
hostname = P.getProperty("Hostname");
portnum = P.getProperty("Portnum");
  }
  catch (Exception ex) {
log.info("Error reading properties file: " + ex.getMessage());
  }

}

}

But now Java2WSDL says:

D:\cvstree\ncnss\NCNWebSvc\classes>java org.apache.axis.wsdl.Java2WSDL -o
../NCNWebSvc.wsdl -l"http://164.179.157.7
3:8080/axis/services/NCNWebSvc" -n
 "urn:NCNWebSvc" -p"com.echo.NCNSS.NCNWebSvc"="urn:NCNWebSvc"
com.echo.NCNSS.NCNWebS
vc


- The class javax.servlet.ServletContext is defined in a java or javax
package and cannot be converted into an xml schem
a type.  An xml schema anyType will be used to define this class in the wsdl
file.
- The class javax.servlet.http.HttpServlet is defined in a java or javax
package and cannot be converted into an xml sch
ema type.  An xml schema anyType will be used to define this class in the
wsdl file.
- The class org.apache.axis.server.AxisServer extends non-bean class
org.apache.axis.AxisEngine.  An xml schema anyType
will be used to define org.apache.axis.server.AxisServer in the wsdl file.
WSDLException: faultCode=OTHER_ERROR: Can't find prefix for
'http://server.axis.apache.org'. Namespace prefixes must be
set on the Definition object using the addNamespace(...) method.:
at com.ibm.wsdl.util.xml.DOMUtils.getPrefix(Unknown Source)
at com.ibm.wsdl.util.xml.DOMUtils.getQualifiedValue(Unknown Source)
at com.ibm.wsdl.util.xml.DOMUtils.printQualifiedAttribute(Unknown
Source)
at com.ibm.wsdl.xml.WSDLWriterImpl.printParts(Unknown Source)
at com.ibm.wsdl.xml.WSDLWriterImpl.printMessages(Unknown Source)
at com.ibm.wsdl.xml.WSDLWriterImpl.printDefinition(Unknown Source)
at com.ibm.wsdl.xml.WSDLWriterImpl.writeWSDL(Unknown Source)
at com.ibm.wsdl.xml.WSDLWriterImpl.getDocument(Unknown Source)
at org.apache.axis.wsdl.fromJava.Emitter.emit(Emitter.java:267)
at org.apache.axis.wsdl.fromJava.Emitter.emit(Emitter.java:334)
at org.apache.axis.wsdl.Java2WSDL.run(Java2WSDL.java:504)
at org.apache.axis.wsdl.Java2WSDL.main(Java2WSDL.java:542)

This reminded me why it was that I changed my class to not extend
AxisServlet in the first place.  Is there a way around this?

Michael D. Spence
Mockingbird Data Systems, Inc.


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



RE: Where should I put properties files

2003-09-19 Thread Shapira, Yoav

Howdy,
I generally disagree, but don't want to start a big discussion, just
solve that guy's problem. ;)

Yoav Shapira
Millennium ChemInformatics


>-Original Message-
>From: Christopher Williams [mailto:[EMAIL PROTECTED]
>Sent: Friday, September 19, 2003 5:03 AM
>To: Tomcat Users List; [EMAIL PROTECTED]
>Subject: Re: Where should I put properties files
>
>Configuration files are a problem area in Java, particularly J2EE.  You
>can:
>1. Use a Preferences object (although I personally have found this
quite
>painful - you need to provide a UI to set up and administer your
>preferences
>and system preferences require admin privileges on Windows).
>2. Put your config file in a directory off the user's home directory.
Use
>System.getProperty("user.home") to retrieve the home directory and
build up
>the path to your file.  Indicate in your documentation that the web
service
>must run in the context of a aprticular user.
>
>
>
>-
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]




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]



Re: Where should I put properties files

2003-09-19 Thread Christopher Williams
Configuration files are a problem area in Java, particularly J2EE.  You can:
1. Use a Preferences object (although I personally have found this quite
painful - you need to provide a UI to set up and administer your preferences
and system preferences require admin privileges on Windows).
2. Put your config file in a directory off the user's home directory.  Use
System.getProperty("user.home") to retrieve the home directory and build up
the path to your file.  Indicate in your documentation that the web service
must run in the context of a aprticular user.



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



RE: Where should I put properties files

2003-09-18 Thread Michael D. Spence
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]

RE: Where should I put properties files

2003-09-18 Thread Shapira, Yoav

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]



RE: Where should I put properties files

2003-09-18 Thread Michael D. Spence
> -Original Message-
> From: Shapira, Yoav [mailto:[EMAIL PROTECTED]
> Sent: Thursday, September 18, 2003 11:09 AM
> To: Tomcat Users List; [EMAIL PROTECTED]
> Subject: RE: Where should I put properties files
> 
> 
> 
> Howdy,
> This is a FAQ, you could read the archives, but here's a 
> summary of the
> two commons solutions:
> 
> - Place properties file on classpath, use the Class#getResource or
> Class#getResourceAsStream method.  
> 
> - Please properties file anywhere under your webapp's root, and use
> ServletContext#getResource or ServletContext#getResourceAsStream.
> 
> Yoav Shapira
> Millennium ChemInformatics
> 

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.

Where should I be looking?

> 
> >-Original Message-
> >From: Michael D. Spence [mailto:[EMAIL PROTECTED]
> >Sent: Thursday, September 18, 2003 10:57 AM
> >To: [EMAIL PROTECTED]
> >Subject: Where should I put properties files
> >
> >I have a web service (call it XYZ) which requires a .properties file.
> I
> >had
> >been putting it in
> >%CATALINA_HOME%\webapps\axis\services\XYZ, with the classes in
> >%CATALINA_HOME%\webapps\axis\services\WEB_INF\classes and 
> using this to
> >open the properties file.
> >
> >File PFile = new File("webapps" + File.separator +
> >  "axis" + File.separator +
> >  "services" + File.separator +
> >  "XYZ" + File.separator + "XYZ.properties");
> >
> >if (!PFile.exists())
> >  throw new CFException("No properties file: " +
> >PFile.getAbsolutePath());
> >
> >This works, but there are two problems:
> >
> >1) If Tomcat is run as a service, I have to put the 
> properties file in
> >%CATALINA_HOME%\webapps\axis\services\XYZ, instead.
> >
> >2) I recently ditched the classes and put XYZ.jar into
> >%CATALINA_HOME%\webapps\axis\services\WEB_INF\lib.  Now, unless I
> hard-code
> >a path for the properties file (e.g., C:\XYZ.properties), the service
> can't
> >find it.
> >
> >How is this issue normally handled?
> >
> >Michael D. Spence
> >Mockingbird Data Systems, Inc.
> >
> >
> >-
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> 
> 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]

RE: Where should I put properties files

2003-09-18 Thread Shapira, Yoav

Howdy,
This is a FAQ, you could read the archives, but here's a summary of the
two commons solutions:

- Place properties file on classpath, use the Class#getResource or
Class#getResourceAsStream method.

- Please properties file anywhere under your webapp's root, and use
ServletContext#getResource or ServletContext#getResourceAsStream.

Yoav Shapira
Millennium ChemInformatics


>-Original Message-
>From: Michael D. Spence [mailto:[EMAIL PROTECTED]
>Sent: Thursday, September 18, 2003 10:57 AM
>To: [EMAIL PROTECTED]
>Subject: Where should I put properties files
>
>I have a web service (call it XYZ) which requires a .properties file.
I
>had
>been putting it in
>%CATALINA_HOME%\webapps\axis\services\XYZ, with the classes in
>%CATALINA_HOME%\webapps\axis\services\WEB_INF\classes and using this to
>open the properties file.
>
>File PFile = new File("webapps" + File.separator +
>  "axis" + File.separator +
>  "services" + File.separator +
>  "XYZ" + File.separator + "XYZ.properties");
>
>if (!PFile.exists())
>  throw new CFException("No properties file: " +
>PFile.getAbsolutePath());
>
>This works, but there are two problems:
>
>1) If Tomcat is run as a service, I have to put the properties file in
>%CATALINA_HOME%\webapps\axis\services\XYZ, instead.
>
>2) I recently ditched the classes and put XYZ.jar into
>%CATALINA_HOME%\webapps\axis\services\WEB_INF\lib.  Now, unless I
hard-code
>a path for the properties file (e.g., C:\XYZ.properties), the service
can't
>find it.
>
>How is this issue normally handled?
>
>Michael D. Spence
>Mockingbird Data Systems, Inc.
>
>
>-
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]




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]



Where should I put properties files (corrected, sorry)

2003-09-18 Thread Michael D. Spence
I have a web service (call it XYZ) which requires a .properties file.  I had
been putting it in
%CATALINA_HOME%\webapps\axis\services\XYZ, with the classes in
%CATALINA_HOME%\webapps\axis\services\WEB_INF\classes and using this to
open the properties file.

File PFile = new File("webapps" + File.separator +
  "axis" + File.separator +
  "services" + File.separator +
  "XYZ" + File.separator + "XYZ.properties");

if (!PFile.exists())
  throw new CFException("No properties file: " +
PFile.getAbsolutePath());

This works, but there are two problems:

1) If Tomcat is run as a service, I have to put the properties file in
%WINSYSDIR%\webapps\axis\services\XYZ, instead.

2) I recently ditched the classes and put XYZ.jar into
%CATALINA_HOME%\webapps\axis\services\WEB_INF\lib.  Now, unless I hard-code
a path for the properties file (e.g., C:\XYZ.properties), the service can't
find it.

How is this issue normally handled?

Michael D. Spence
Mockingbird Data Systems, Inc.


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



Where should I put properties files

2003-09-18 Thread Michael D. Spence
I have a web service (call it XYZ) which requires a .properties file.  I had
been putting it in
%CATALINA_HOME%\webapps\axis\services\XYZ, with the classes in
%CATALINA_HOME%\webapps\axis\services\WEB_INF\classes and using this to
open the properties file.

File PFile = new File("webapps" + File.separator +
  "axis" + File.separator +
  "services" + File.separator +
  "XYZ" + File.separator + "XYZ.properties");

if (!PFile.exists())
  throw new CFException("No properties file: " +
PFile.getAbsolutePath());

This works, but there are two problems:

1) If Tomcat is run as a service, I have to put the properties file in
%CATALINA_HOME%\webapps\axis\services\XYZ, instead.

2) I recently ditched the classes and put XYZ.jar into
%CATALINA_HOME%\webapps\axis\services\WEB_INF\lib.  Now, unless I hard-code
a path for the properties file (e.g., C:\XYZ.properties), the service can't
find it.

How is this issue normally handled?

Michael D. Spence
Mockingbird Data Systems, Inc.


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