当前位置: 代码迷 >> Web前端 >> cxf 没法set WebServiceContext
  详细解决方案

cxf 没法set WebServiceContext

热度:1072   发布时间:2012-11-07 09:56:10.0
cxf 无法set WebServiceContext

在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(): 
?

?

?

?

  相关解决方案