axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sagara Gunathunga <sagara.gunathu...@gmail.com>
Subject Re: Axis2 service and spring problem, can't find Spring's ApplicationContext.
Date Thu, 02 Apr 2009 17:52:48 GMT
As mentioned in previous mails "ApplicationContextHolder.getContext()"
is not required to  handle this , i think reading some Spring docs
will helpful to you because this is a problem with the the way you
retrieve beans from spring context.

First create your service as a POJO service and configure it within
SpringContext , then as you already did ,expose this service bean as a
web service using Axis2 "SpringServletContextObjectSupplier"  in this
case you don't need to  modify your java codes to expose your spring
bean as a web service.


Thanks ,

On Thu, Apr 2, 2009 at 10:18 PM, Azazel Se <azazel.se@hotmail.com> wrote:
>> From: robertlazarski@gmail.com
>>
>> "ApplicationContextHolder.getContext()" isn't needed when using
>> SpringServletContextObjectSupplier. If spring and axis2 are working
>> together, you are done. You have to configure Spring to use
>> ApplicationContextHolder, otherwise it will return null values.
>>
>> - R
>
>> From: sagara.gunathunga@gmail.com
>> To: axis-user@ws.apache.org
>
>> Here, how you try to use context .and can you provide error trace you
>> got ....? i cant get any clue with supplied details .
>> > .   ApplicationContext ctx = ApplicationContextHolder.getContext();
>> I don't think you need to have this line to access SpringContext
>> explicitly , because "MyServ " is already a Spring manged bean. if you
>> want to access any other bean inside "MyServ " use Spring injection
>> instead of access through ApplicationContextHolder.
>
>
>
>
> Hi, thanks for the replies.
>
> I have an application which I didn't make which uses spring, it has an API
> which hides the details and preferably I don't add any more stuff to it. The
> goal is to just use a few of the methods and get returns as normal and not
> interact directly with spring. I have never used Spring before so my
> knowledge about the innerworkings is small but if I get the API to work I
> shouldn't need to either. The springappl needs the context at initiating. I
> have tested it in a jsp file and it works, but I want to move it to a web
> service. In the jsp file I had the same context stuff added to the web.xml
> and this is in the jsp file:
>
> MyApplWithSpring  ap = new
> MyApplWithSpring(WebApplicationContextUtils.getWebApplicationContext(getServletContext()));
>
> This worked and I could use some of its methods afterwards.
> So I thought it would work in the web service as well if I used
> ApplicationContextHolder.getContext() and used new
> MyApplWithSpring(ApplicationContextHolder.getContext()). If possible how do
> I configure spring to use the ApplicationContextHolder so that it isn't
> null? Or is there any other(/better) way I can do this?
>
> -Az.
>
>
>
>
> New java class, only added the fourth line and this gives an error since con
> is null:
> -----------------------
> public class MyServ {
>  public String serExe() {
>   ApplicationContext con = ApplicationContextHolder.getContext();
>   MyApplWithSpring ap = new MyApplWithSpring(con);
>   return "testWithSpringAppl";
>  }
> }
>
>
> Exception in eclipse when running client:
> ---------------------------------------
> Exception in thread "main" org.apache.axis2.AxisFault: Cannot attach a
> profile to a null context
>  at
> org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:512)
>  at
> org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370)
>  at
> org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
>  at
> org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
>  at
> org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
>  at xyz.MyServStub.serExe(MyServStub.java:183)
>  at xyz.MyServClient.main(MyServClient.java:17)
>
>
> Output of Exception at runtime in the tomcat server:
> --------------------------------------------------
> ERROR - RPCMessageReceiver.invokeBusinessLogic(157) | Cannot attach a
> profile to
>  a null context
> java.lang.reflect.InvocationTargetException
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
> java:39)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
> sorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at
> org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.jav
> a:165)
>         at
> org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic
> (RPCMessageReceiver.java:102)
>         at
> org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusines
> sLogic(AbstractInOutMessageReceiver.java:40)
>         at
> org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMe
> ssageReceiver.java:100)
>         at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:176)
>         at
> org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostReq
> uest(HTTPTransportUtils.java:275)
>         at
> org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:1
> 33)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
> icationFilterChain.java:290)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
> ilterChain.java:206)
>         at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
> alve.java:233)
>         at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
> alve.java:191)
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
> ava:128)
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
> ava:102)
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
> ve.java:109)
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
> a:286)
>         at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
> :845)
>         at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
> ss(Http11Protocol.java:583)
>         at
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44
> 7)
>         at java.lang.Thread.run(Thread.java:619)
> Caused by:
> net.sf.taverna.t2.platform.spring.profile.ContextProfileException: Ca
> nnot attach a profile to a null context
>         at
> net.sf.taverna.t2.platform.spring.profile.AbstractContextProfile.<ini
> t>(AbstractContextProfile.java:66)
>         at
> net.sf.taverna.t2.platform.taverna.TavernaBaseProfile.<init>(TavernaB
> aseProfile.java:48)
>         at xyz.MyServ.serExe(MyServ.java:11)
>         ... 25 more
> ERROR - AxisEngine.receive(212) | Cannot attach a profile to a null context
> org.apache.axis2.AxisFault: Cannot attach a profile to a null context
>         at
> org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic
> (RPCMessageReceiver.java:158)
>
> ________________________________
> Få gratisprogrammene fra Windows Live™. Last ned her.



-- 
Sagara Gunathunga

Blog - http://ssagara.blogspot.com
Web - http://sagaras.awardspace.com/

Mime
View raw message