在cxf开发webservice ,在处理IP的时候,
?
@Resource private WebServiceContext context;
?
出现很奇异的异常:
?
Caused by: java.lang.IllegalArgumentException: Can not set javax.xml.ws.WebServiceContext field com.ipWeb.wsContext to $Proxy46 at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146) at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150) at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37) at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:57) at java.lang.reflect.Field.set(Field.java:657) 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) ... 52 more?
?? 但有的工程不会,郁闷!
?
解决方法:
一、
@Resource(name = "org.apache.cxf.jaxws.context.WebServiceContextImpl") private WebServiceContext context;?
二、
private WebServiceContext context = new org.apache.cxf.jaxws.context.WebServiceContextImpl():?
?
?
?