Most likely, what is happening, is that the AOP stuff is hiding the private
field behind a proxy or similar which is preventing it from being injected.
You could probably get around it by doing:
private WebServiceContext webServiceContext;
@Resouce
public void setWebServiceContext(WebServiceContext ctx) {
webServiceContext = ctx.
}
By going through a public method, the proxy should be able to proxy that as
well.
Dan
On Mon November 9 2009 6:48:58 pm Pydipati, Karuna wrote:
> Hi
>
> I have a weird issue. I have a JAX-WS java-first webservice using CXF
> and Spring. I have WebServiceContext in my Implementer class. Here is
> snippet of my Implementer class
>
> @WebService(endpointInterface = "com.xxx.ws.soap.XXXService",
> serviceName = "XXXService")
> @WebFault(targetNamespace = "com.xxx.ws.soap", name = "XXXFault",
> faultBean = "XXXFault")
> public class XXXServiceImpl implements XXXService {
>
> @Resource
> private WebServiceContext webServiceContext;
>
> @Throttle
> public PatientMatchResp getSomeMethod()
> throws ApplicationFault {
> ....
> ....
> ....
> }
>
> I have a custom annotation @Throttle and would like to do some work
> (basically throttling the method such as way that this service is not
> abused by users when exposed to public) on that method using Spring AOP.
>
>
> 1) My issue is when I started my Tomcat with this implementation, I am
> getting this error. Again, this is at the startup time of Tomcat time.
> Not at some invocation of webservice time. If I comment either
> WebServiceContext OR @Throttle, then, things are OK. Why is my custom
> annotation is giving problem for CXF startup?
>
> 2) Second questions is.. is there a easy way to get hold of
> HttpServletRequest into my Aspect (Spring AOP). I don't know whether
> this is a right forum or not. Currently, I am trying to get hold of
> WebServiceContext using reflections API in my Aspect class and trying to
> get HttpServletRequest. Is there an example where I can write a CXF
> Handler/Filter and put WebServiceContext into ThreadLocal so that I can
> get it wherever I want down-the-line(here..in this case my Aspect
> class)?
>
> Caused by: javax.xml.ws.WebServiceException: Creation of Endpoint failed
> at
> org.apache.cxf.jaxws.JaxWsServerFactoryBean.init(JaxWsServerFactoryBean.
> java:181)
> at
> org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBea
> n.java:168)
> at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:346)
> at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:259)
> at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:209)
> at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:404)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> a:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> Impl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
> tory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1413
> )
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
> tory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1374)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
> tory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334)
> ... 39 more
> Caused by: java.lang.IllegalArgumentException
> at
> sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.ja
> va:37)
> at
> sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorI
> mpl.java:57)
> at java.lang.reflect.Field.set(Field.java:656)
> at
> org.apache.cxf.common.injection.ResourceInjector.injectField(ResourceInj
> ector.java:283)
> at
> org.apache.cxf.common.injection.ResourceInjector.visitField(ResourceInje
> ctor.java:167)
> at
> org.apache.cxf.common.annotation.AnnotationProcessor.processFields(Annot
> ationProcessor.java:101)
> at
> org.apache.cxf.common.annotation.AnnotationProcessor.accept(AnnotationPr
> ocessor.java:69)
> at
> org.apache.cxf.common.injection.ResourceInjector.inject(ResourceInjector
> .java:81)
> at
> org.apache.cxf.jaxws.JaxWsServerFactoryBean.injectResources(JaxWsServerF
> actoryBean.java:221)
> at
> org.apache.cxf.jaxws.JaxWsServerFactoryBean.init(JaxWsServerFactoryBean.
> java:175)
> ... 51 more
> Nov 9, 2009 3:32:14 PM org.apache.catalina.core.ApplicationContext log
>
>
>
> Regards
>
> Karuna Pydipati
>
> StubHub/eBay - Platform & Services
>
> Phone: (415)222-8752
>
> Email: [email protected] <mailto:[email protected]>
>
--
Daniel Kulp
[email protected]
http://www.dankulp.com/blog