You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Susan Barretta <ba...@itmedicine.net> on 2003/06/06 20:13:12 UTC
Trying to find resource directory location
Hi all,
I have Axis services all zipped up in a jar under axis\web-inf\lib and the
services run fine. This is Axis 1.1 under Tomcat 4.1.24.
One service is deployed as follows (from my server-config.wsdd):
<service name="DICOMPacsProvider" provider="java:RPC">
<parameter name="allowedMethods" value="getDicomProvider"/>
<parameter name="className"
value="DICOMSoapServices.dicomPacsProvider.DICOMPacsProvider"/>
<beanMapping
languageSpecificType="java:DICOMObjects.services.DICOMPacsNode"
qname="ns1:DICOMPacsNode" xmlns:ns1="urn:DICOMPacsProvider"/>
</service>
My services use xml config files that up to now I had zipped up in the jar,
and which I had been accessing with getResourceAsStream(). However we want
those xml config files to be external to the jar so that we can easily
modify them without having to modify the service jar.
However, I now need to get the directory path to those xml files and I
cannot figure out how to communicate to my service any Axis context
information. I was hoping to do something like getRealPath("/web-inf").
I have tried the following in order to get context information, however I
seem to blow up with a NullPointerException when I try to getServletContext():
try {
Class axisClass
=
Class.forName("org.apache.axis.transport.http.AxisServletBase",false,this.getClass().getClassLoader());
if (axisClass == null) {
System.out.println ("DOES NOT WORK - returned class is null.") ;
} else {
System.out.println ("IT WORKS - found a class!") ; // YES
}
AxisServletBase asb = (AxisServletBase)axisClass.newInstance();
if (asb == null) {
System.out.println ("CANNOT find AXIS BASE.") ;
} else {
System.out.println("IT WORKS - found Axis base.") ; // YES
System.out.println ("LOAD COUNTER is " +
asb.getLoadCounter()); // RETURNS 2
}
System.out.println ("ABOUT to try getting CONTEXT...") ; // YES
I SEE THIS
ServletContext sc = asb.getServletContext(); // BLOWS UP HERE
System.out.println ("GOT context...") ; // NEVER
GET TO HERE
if (sc == null) {
System.out.println ("WHYYYY is SERVLET CONTEXT NULL?") ; //
I NEVER SEE THIS
} else {
System.out.println ("FOUND Servlet Context!") ; // NEVER SEE
THIS EITHER
String home = sc.getRealPath("/") ;
System.out.println ("HOME DIRECTORY for applet is " + home) ;
}
My service classes are not subclassed from anything in the Axis API.
Any ideas?????
Thanks,
Susan
RE: Trying to find resource directory location
Posted by Susan Barretta <ba...@itmedicine.net>.
That's true, I did discover where the servlet was, but that is not where my
service is. Rather
than do something convoluted and strip \bin off of $CATALINA_HOME\bin and
appending
webapps\axis\web-inf\lib, I was hoping for a better way to locate my service.
Thanks anyhow,
Susan
At 02:57 PM 6/6/2003 -0400, mser wrote:
>I had a similar problem loading some configuration files from my web
>service. The answer is $CATALINA_HOME/bin. After all it is a servlet.
>
>Somewhere in Axis land I found this code which revealed the mystery:
>
>MessageContext msgContext = MessageContext.getCurrentContext();
>String rootDir =
>msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETLOCATI
>ON).toString();
>
>Michael Ser
>Netweave Integrated Solutions, Inc.
>
>
>-----Original Message-----
>From: Susan Barretta [mailto:barretta@itmedicine.net]
>Sent: Friday, June 06, 2003 2:13 PM
>To: axis-user@ws.apache.org
>Subject: Trying to find resource directory location
>
>Hi all,
>
>I have Axis services all zipped up in a jar under axis\web-inf\lib and
>the
>services run fine. This is Axis 1.1 under Tomcat 4.1.24.
>
>One service is deployed as follows (from my server-config.wsdd):
>
> <service name="DICOMPacsProvider" provider="java:RPC">
> <parameter name="allowedMethods" value="getDicomProvider"/>
> <parameter name="className"
>value="DICOMSoapServices.dicomPacsProvider.DICOMPacsProvider"/>
> <beanMapping
>languageSpecificType="java:DICOMObjects.services.DICOMPacsNode"
>qname="ns1:DICOMPacsNode" xmlns:ns1="urn:DICOMPacsProvider"/>
> </service>
>
>My services use xml config files that up to now I had zipped up in the
>jar,
>and which I had been accessing with getResourceAsStream(). However we
>want
>those xml config files to be external to the jar so that we can easily
>modify them without having to modify the service jar.
>
>However, I now need to get the directory path to those xml files and I
>cannot figure out how to communicate to my service any Axis context
>information. I was hoping to do something like getRealPath("/web-inf").
>
>I have tried the following in order to get context information, however
>I
>seem to blow up with a NullPointerException when I try to
>getServletContext():
>
> try {
> Class axisClass
>=
>Class.forName("org.apache.axis.transport.http.AxisServletBase",false,thi
>s.getClass().getClassLoader());
> if (axisClass == null) {
> System.out.println ("DOES NOT WORK - returned class is
>null.") ;
> } else {
> System.out.println ("IT WORKS - found a class!") ; //
>YES
> }
>
> AxisServletBase asb =
>(AxisServletBase)axisClass.newInstance();
>
> if (asb == null) {
> System.out.println ("CANNOT find AXIS BASE.") ;
> } else {
> System.out.println("IT WORKS - found Axis base.") ; // YES
> System.out.println ("LOAD COUNTER is " +
>asb.getLoadCounter()); // RETURNS 2
> }
>
> System.out.println ("ABOUT to try getting CONTEXT...") ; //
>YES
>I SEE THIS
> ServletContext sc = asb.getServletContext(); // BLOWS
>UP HERE
> System.out.println ("GOT context...") ; //
>NEVER
>GET TO HERE
>
> if (sc == null) {
> System.out.println ("WHYYYY is SERVLET CONTEXT NULL?") ;
>//
>I NEVER SEE THIS
> } else {
> System.out.println ("FOUND Servlet Context!") ; // NEVER
>SEE
>THIS EITHER
> String home = sc.getRealPath("/") ;
> System.out.println ("HOME DIRECTORY for applet is " +
>home) ;
> }
>
>
>My service classes are not subclassed from anything in the Axis API.
>
>Any ideas?????
>
>Thanks,
>Susan
-- Susan
RE: Trying to find resource directory location
Posted by mser <ms...@netweave.com>.
I had a similar problem loading some configuration files from my web
service. The answer is $CATALINA_HOME/bin. After all it is a servlet.
Somewhere in Axis land I found this code which revealed the mystery:
MessageContext msgContext = MessageContext.getCurrentContext();
String rootDir =
msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETLOCATI
ON).toString();
Michael Ser
Netweave Integrated Solutions, Inc.
-----Original Message-----
From: Susan Barretta [mailto:barretta@itmedicine.net]
Sent: Friday, June 06, 2003 2:13 PM
To: axis-user@ws.apache.org
Subject: Trying to find resource directory location
Hi all,
I have Axis services all zipped up in a jar under axis\web-inf\lib and
the
services run fine. This is Axis 1.1 under Tomcat 4.1.24.
One service is deployed as follows (from my server-config.wsdd):
<service name="DICOMPacsProvider" provider="java:RPC">
<parameter name="allowedMethods" value="getDicomProvider"/>
<parameter name="className"
value="DICOMSoapServices.dicomPacsProvider.DICOMPacsProvider"/>
<beanMapping
languageSpecificType="java:DICOMObjects.services.DICOMPacsNode"
qname="ns1:DICOMPacsNode" xmlns:ns1="urn:DICOMPacsProvider"/>
</service>
My services use xml config files that up to now I had zipped up in the
jar,
and which I had been accessing with getResourceAsStream(). However we
want
those xml config files to be external to the jar so that we can easily
modify them without having to modify the service jar.
However, I now need to get the directory path to those xml files and I
cannot figure out how to communicate to my service any Axis context
information. I was hoping to do something like getRealPath("/web-inf").
I have tried the following in order to get context information, however
I
seem to blow up with a NullPointerException when I try to
getServletContext():
try {
Class axisClass
=
Class.forName("org.apache.axis.transport.http.AxisServletBase",false,thi
s.getClass().getClassLoader());
if (axisClass == null) {
System.out.println ("DOES NOT WORK - returned class is
null.") ;
} else {
System.out.println ("IT WORKS - found a class!") ; //
YES
}
AxisServletBase asb =
(AxisServletBase)axisClass.newInstance();
if (asb == null) {
System.out.println ("CANNOT find AXIS BASE.") ;
} else {
System.out.println("IT WORKS - found Axis base.") ; // YES
System.out.println ("LOAD COUNTER is " +
asb.getLoadCounter()); // RETURNS 2
}
System.out.println ("ABOUT to try getting CONTEXT...") ; //
YES
I SEE THIS
ServletContext sc = asb.getServletContext(); // BLOWS
UP HERE
System.out.println ("GOT context...") ; //
NEVER
GET TO HERE
if (sc == null) {
System.out.println ("WHYYYY is SERVLET CONTEXT NULL?") ;
//
I NEVER SEE THIS
} else {
System.out.println ("FOUND Servlet Context!") ; // NEVER
SEE
THIS EITHER
String home = sc.getRealPath("/") ;
System.out.println ("HOME DIRECTORY for applet is " +
home) ;
}
My service classes are not subclassed from anything in the Axis API.
Any ideas?????
Thanks,
Susan