This way it works:
> MessageContext ctx = MessageContext.getCurrentMessageContext();
> ServletContext sr = (ServletContext)
ctx.getProperty("transport.http.servletContext");
> System.out.println("xsltPath: " + sr.getInitParameter("xsltPath"));
regards
Simon
Suriya Simsuwat wrote:
Thank Simon for your reply. I have tried it, but always got the
java.lang.NullPointerException. Any suggestion?
My context.xml data located in <Tomcat-home>\webapps\axis2\META-INF :
<Context>
<Parameter name="xsltPath" value="xslt" override="false" />
</Context>
My SOAP server class :
/**
* HelloServiceSkeleton java skeleton for the axisService
*/
* *
*public* *class* HelloServiceSkeleton *implements*
HelloServiceSkeletonInterface {
/**
* Auto generated method signature
* [EMAIL PROTECTED] helloRequest
*/
*public* com.glovia.www.hello.HelloResponse sayHello(
com.glovia.www.hello.HelloRequest helloRequest) {
System./out/.println("Print properties from Tomcat context.xml");
String xsltPath = "";
*try* {
MessageContext msgC = MessageContext./getCurrentMessageContext/();
System./out/.println("Get MessageContext");
ServletContext context = ((HttpServlet) msgC
.getProperty(HTTPConstants./MC_HTTP_SERVLET/))
.getServletContext();
System./out/.println("Get ServletContext");
xsltPath = context.getInitParameter("xsltPath");
System./out/.println("Get xsltPath");
xsltPath = context.getInitParameter("xsltPath");
} *catch* (Exception e) {
e.printStackTrace();
}
System./out/.println("XsltPath : "+xsltPath);
HelloResponse resp = *new* HelloResponse();
resp.setHelloResponse("Hi "+ helloRequest.getHelloRequest());
*return* resp;
}
}
The error message :
java.lang.NullPointerException
at
com.glovia.service.HelloServiceSkeleton.sayHello(HelloServiceSkeleton
.java:48)
at
com.glovia.service.HelloServiceMessageReceiverInOut.invokeBusinessLog
ic(HelloServiceMessageReceiverInOut.java:48)
at
org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBus
inessLogic(AbstractInOutSyncMessageReceiver.java:42)
at
org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMe
ssageReceiver.java:96)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:145)
at
org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostReq
uest(HTTPTransportUtils.java:275)
at
org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:1
20)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:269)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:188)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:174)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:117)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:108)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:174)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:874)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
rocessConnection(Http11BaseProtocol.java:665)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:528)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol
lowerWorkerThread.java:81)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:689)
at java.lang.Thread.run(Thread.java:595)
*/Simon Steinacker <[EMAIL PROTECTED]>/* wrote:
Something like this
> MessageContext msgC=MessageContext.getCurrentContext();
> ServletContext
context=((HttpServlet)msgC.getProperty(HTTPConstants.MC_HTTP_SERVLET)).getServletContext();
should work.
Generally speaking you can get a lot of properties concerning the
current http and soap message by using the
MessageContext.getProperty(...) method. Parameters taht can be
used for
this are located in org.apache.axis2.Constants or HTTPConstants or
whatever.
Hope that helped,
best regards,
Simon
Suriya Simsuwat wrote:
> Hi all,
>
> I would like to know is it possible to get the properties'
values from
> the file 'context.xml' in \webapps\axis2\META-INF.
>
> The example of context.xml
>
>
>
>
>
>
>
> It said on Tomcat document that the value can be retrieved by
calling
> |ServletContext.getInitParameter(), |but I do not know how to
get this
> data via the Axis2 server skeleton class. Thank you for any help in
> advance.
>
> Cheers,
>
> Suriya
>
>
------------------------------------------------------------------------
> Looking for last minute shopping deals? Find them fast with Yahoo!
> Search.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
------------------------------------------------------------------------
Never miss a thing. Make Yahoo your homepage.
<http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]