I kind of found the issue. Since, I am doing my own Spring-AOP, I need to modify the jaxws:endpoint XML config as follows. <jaxws:endpoint id="XXXService" implementorClass="com.xxx.ws.soap.XXXServiceImpl" implementor="#xxxServiceImpl" address="/XXXService"/> Because of this, since Spring works on proxies, somehow, @Resource (WebServiceContext ) is failing. This is because ResourceInjector (CXF class) works on Fields (using Reflections API) rather than on methods. If the accessing of WebServiceContext is done using Methods (Reflections API), it would not be a problem because proxies have methods too. So it appears that, we can not have any custom annotations in CXF implementor classes. I see this is a limitation of CXF (at least for now). I might need to do some other way of doing Throttling in stead of using Custom annotations. Has anybody done any custom annotations on CXF implementor class which have @Resource (WebServiceContext)?
Regards Karuna Pydipati StubHub/eBay - Platform & Services Phone: (415)222-8752 Email: [email protected] <mailto:[email protected]> ________________________________ From: Pydipati, Karuna Sent: Monday, November 09, 2009 3:49 PM To: [email protected]; 'Sergey Beryozkin'; Sergey Beryozkin Subject: CXF and Custom Annotation 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]>
