Hi

> This is because ResourceInjector (CXF class) works on Fields (using 
> Reflections API) rather than on methods.

Perhaps it is worth opening an enhancement request against JAXWS runtime ?
In meantime, any chnace that you can force Sprion AOP to use CGLIB ? It might 
help.

> I might need to do some other way of doing Throttling in stead of using 
> Custom annotations.

You can probably register a custom input CXF interceptor and configure it with 
the names of the methods to be throttled but I'm not right now how to get the 
name of the method to be invoked from the Message. Another option is to 
register a custom JAXWS invoker (configured with the names) and check the 
Method there

cheers, Sergey
  ----- Original Message ----- 
  From: Pydipati, Karuna 
  To: [email protected] ; Sergey Beryozkin ; Sergey Beryozkin 
  Sent: Tuesday, November 10, 2009 11:20 PM
  Subject: RE: CXF and Custom Annotation


  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]







------------------------------------------------------------------------------
  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(JaxWsServerFactoryBean.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.java:39)
   at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1413)
   at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1374)
   at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334)
   ... 39 more
  Caused by: java.lang.IllegalArgumentException
   at 
sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37)
   at 
sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:57)
   at java.lang.reflect.Field.set(Field.java:656)
   at 
org.apache.cxf.common.injection.ResourceInjector.injectField(ResourceInjector.java:283)
   at 
org.apache.cxf.common.injection.ResourceInjector.visitField(ResourceInjector.java:167)
   at 
org.apache.cxf.common.annotation.AnnotationProcessor.processFields(AnnotationProcessor.java:101)
   at 
org.apache.cxf.common.annotation.AnnotationProcessor.accept(AnnotationProcessor.java:69)
   at 
org.apache.cxf.common.injection.ResourceInjector.inject(ResourceInjector.java:81)
   at 
org.apache.cxf.jaxws.JaxWsServerFactoryBean.injectResources(JaxWsServerFactoryBean.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]



Reply via email to