Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java CXF错误解组错误取消支持操作异常_Java_Jax Ws_Cxf - Fatal编程技术网

Java CXF错误解组错误取消支持操作异常

Java CXF错误解组错误取消支持操作异常,java,jax-ws,cxf,Java,Jax Ws,Cxf,TL;由于某些原因,我无法在使用CXF的Java first web服务中解组一个相当简单的对象 我有一个Java First CXF Web服务,其API类似于: @WebMethod public SearchResponse search(@WebParam(name = "searchRequest") SearchRequest searchRequest); 响应(不会解组的类)大致如下: public class SearchResponse { private

TL;由于某些原因,我无法在使用CXF的Java first web服务中解组一个相当简单的对象

我有一个Java First CXF Web服务,其API类似于:

@WebMethod
public SearchResponse search(@WebParam(name = "searchRequest") SearchRequest searchRequest);    
响应(不会解组的类)大致如下:

public class SearchResponse {

    private List<SearchResult> results;
    public List<SearchResult> getResults() {
        return results;
    }
    public void setResults(List<SearchResult> results) {
        this.results = results;
    }
}
我可以通过soapui调用这个服务,它工作得非常好。但是,当我使用jaxws客户端调用时,会出现一个错误:

javax.xml.ws.soap.SOAPFaultException: Unmarshalling Error: null 
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:143)
    at $Proxy67.search(Unknown Source)
    at com.blah.MyTest.curseYouSearch(MyTest.java:76)
    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:597)
    at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
    at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
    at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
    at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
    at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
    at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
    at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
    at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
    at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
    at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
    at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.UnsupportedOperationException
    at java.util.AbstractList.add(AbstractList.java:131)
    at java.util.AbstractList.add(AbstractList.java:91)
    at com.sun.xml.internal.bind.v2.runtime.reflect.Lister$CollectionLister.addToPack(Lister.java:290)
    at com.sun.xml.internal.bind.v2.runtime.reflect.Lister$CollectionLister.addToPack(Lister.java:254)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Scope.add(Scope.java:106)
    at com.sun.xml.internal.bind.v2.runtime.property.ArrayERProperty$ReceiverImpl.receive(ArrayERProperty.java:195)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.endElement(UnmarshallingContext.java:524)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleEndElement(StAXStreamConnector.java:206)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:170)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:351)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:330)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:610)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:530)
    at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:114)
    at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:99)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
    at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:658)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2139)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:2022)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1947)
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:632)
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:472)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:302)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:123)
    ... 24 more
我可以在AbstractList.add上设置一个断点,根据生成的堆栈,似乎解组器正在尝试添加到空列表中,这当然是不可变的:

Thread [main] (Suspended (breakpoint at line 131 in AbstractList))  
    Collections$EmptyList(AbstractList<E>).add(int, E) line: 131    
    Collections$EmptyList(AbstractList<E>).add(E) line: 91  
    Lister$CollectionLister<BeanT,T>.addToPack(T, Object) line: 290 
    Lister$CollectionLister<BeanT,T>.addToPack(Object, Object) line: 254    
    Scope<BeanT,PropT,ItemT,PackT>.add(Accessor<BeanT,PropT>, Lister<BeanT,PropT,ItemT,PackT>, ItemT) line: 106 
    ArrayERProperty$ReceiverImpl.receive(UnmarshallingContext$State, Object) line: 195  
    UnmarshallingContext.endElement(TagName) line: 524  
    StAXStreamConnector.handleEndElement() line: 206    
    StAXStreamConnector.bridge() line: 170  
    UnmarshallerImpl.unmarshal0(XMLStreamReader, JaxBeanInfo) line: 351 
    UnmarshallerImpl.unmarshal(XMLStreamReader, Class<T>) line: 330 
    JAXBEncoderDecoder.unmarshall(Unmarshaller, Object, QName, Class<?>, boolean) line: 610 
    JAXBEncoderDecoder.unmarshall(Unmarshaller, Object, MessagePartInfo, boolean) line: 530 
    DataReaderImpl<T>.read(MessagePartInfo, T) line: 114    
    DocLiteralInInterceptor.handleMessage(Message) line: 99 
    PhaseInterceptorChain.doIntercept(Message) line: 236    
    ClientImpl.onMessage(Message) line: 658 
    HTTPConduit$WrappedOutputStream.handleResponseInternal() line: 2139 
    HTTPConduit$WrappedOutputStream.handleResponse() line: 2022 
    HTTPConduit$WrappedOutputStream.close() line: 1947  
    HTTPConduit(AbstractConduit).close(Message) line: 66    
    HTTPConduit.close(Message) line: 632    
    MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(Message) line: 62 
    PhaseInterceptorChain.doIntercept(Message) line: 236    
    ClientImpl.invoke(BindingOperationInfo, Object[], Map<String,Object>, Exchange) line: 472   
    ClientImpl.invoke(BindingOperationInfo, Object[], Exchange) line: 302   
    ClientImpl.invoke(BindingOperationInfo, Object...) line: 254    
    JaxWsClientProxy(ClientProxy).invokeSync(Method, BindingOperationInfo, Object[]) line: 73   
    JaxWsClientProxy.invoke(Object, Method, Object[]) line: 123 
    ...endless stack lines omitted...
Thread[main](挂起(AbstractList中第131行的断点))
集合$EmptyList(AbstractList).add(int,E)行:131
集合$EmptyList(AbstractList).add(E)行:91
Lister$CollectionLister.addToPack(T,对象)行:290
Lister$CollectionLister.addToPack(对象,对象)行:254
Scope.add(访问器、列表器、ItemT)行:106
ArrayERProperty$ReceiverImpl.receive(解组上下文$State,Object)行:195
解组上下文.endElement(标记名)行:524
StAXStreamConnector.handleEndElement()行:206
StAXStreamConnector.bridge()行:170
UnmarshallerImpl.unmarshal0(XMLStreamReader,JaxBeanInfo)行:351
UnmarshallerImpl.unmarshal(XMLStreamReader,类)行:330
解组器(解组器、对象、QName、类、布尔值)行:610
解组器(解组器、对象、MessagePartInfo、布尔值)行:530
DataReaderImpl.read(MessagePartInfo,T)行:114
docliteralinterceptor.handleMessage(消息)行:99
PhaseInterceptorChain.doIntercept(消息)行:236
ClientImpl.onMessage(消息)行:658
httpconductor$wrappedoutStream.handleResponseInternal()行:2139
httpconductor$wrappedoutStream.handleResponse()行:2022
httpconductor$wrappedoutpstream.close()行:1947
HttpConductor(AbstractConductor).关闭(消息)行:66
httpconductor.close(消息)行:632
MessageSenderInterceptor$MessageSenderdingInterceptor.handleMessage(消息)行:62
PhaseInterceptorChain.doIntercept(消息)行:236
ClientImpl.invoke(BindingOperationInfo,Object[],Map,Exchange)行:472
ClientImpl.invoke(BindingOperationInfo,Object[],Exchange)行:302
ClientImpl.invoke(BindingOperationInfo,Object…)行:254
JaxWsClientProxy(ClientProxy).invokeSync(方法,BindingOperationInfo,对象[])行:73
调用(对象、方法、对象[])行:123
…省略了无休止的堆栈线。。。
我的客户端在Spring中设置为jaxws:client:

<jaxws:client id="searchServiceClient"
    serviceClass="qualified.class.of.Service"
    address="${url.searchService}">
</jaxws:client>   

我们有许多其他web服务,它们以非常相似的方式返回列表,并且工作良好;我有点不知所措,不知道这个有什么不同

系统使用Java 6、CXF 2.2.3


任何建议都是非常受欢迎的。

我想我也遇到了同样的问题,至少在我的情况下,我有一个解决方案,它可能会帮助你

这里的用例与您的略有不同,因为我正在从一个平面应用程序读取一个XML文件。没有网络交互

配置文件的重要元素包括:

private static final List<StrategyConfiguration<Transaction>> EMPTY_CONFIGURATION_LIST = Collections.emptyList();
private List<StrategyConfiguration<Transaction>> configurations;
@XmlElementWrapper(name = "boundaries")
@XmlElements({
    @XmlElement(name = "a", type = abtStrategyConfig.class),
    @XmlElement(name = "b", type = bbtStrategyConfig.class),
    @XmlElement(name = "c", type = cbtStrategyConfig.class)
})
public void setConfigurations(List<StrategyConfiguration<Transaction>> configurations) {
    this.configurations = configurations;
}
public List<StrategyConfiguration<Transaction>> getConfigurations() {
    if (configurations == null) {
        return EMPTY_CONFIGURATION_LIST;
    }
    return configurations;
}
private static final List EMPTY_CONFIGURATION_List=Collections.emptyList();
私有列表配置;
@XmlElementWrapper(name=“边界”)
@XmlElements({
@XmlElement(name=“a”,type=abtStrategyConfig.class),
@XmlElement(name=“b”,type=bbtStrategyConfig.class),
@XmlElement(name=“c”,type=cbtStrategyConfig.class)
})
公共配置(列表配置){
这是配置=配置;
}
公共列表getConfigurations(){
if(配置==null){
返回空的配置列表;
}
返回配置;
}
我没有时间调查“为什么”,但调试运行显示了导致问题的“原因”。在setter之前调用了空安全的“get”访问器。我想这是为了提供类型安全检查。返回的“空”列表为非空,然后用作后续集合的基础

我发现,通过提供一个直接的setter&getter,然后为外部使用提供一个空安全getter,我消除了这个错误

private static final List<StrategyConfiguration<Transaction>> EMPTY_CONFIGURATION_LIST = Collections.emptyList();
private List<StrategyConfiguration<Transaction>> configurations;
@XmlElementWrapper(name = "boundaries")
@XmlElements({
    @XmlElement(name = "a", type = abtStrategyConfig.class),
    @XmlElement(name = "b", type = bbtStrategyConfig.class),
    @XmlElement(name = "c", type = cbtStrategyConfig.class)
})
public void setJaxBConfigurations(List<StrategyConfiguration<Transaction>> configurations) {
    this.configurations = configurations;
}
public List<StrategyConfiguration<Transaction>> getJaxBConfigurations() {
    return configurations;
}
public List<StrategyConfiguration<Transaction>> getConfigurations() {
    List<StrategyConfiguration<Transaction>> response = getConfigurationConfigs();
    if (response == null) {
        response = EMPTY_CONFIGURATION_LIST;
    }
    return response;
}
private static final List EMPTY_CONFIGURATION_List=Collections.emptyList();
私有列表配置;
@XmlElementWrapper(name=“边界”)
@XmlElements({
@XmlElement(name=“a”,type=abtStrategyConfig.class),
@XmlElement(name=“b”,type=bbtStrategyConfig.class),
@XmlElement(name=“c”,type=cbtStrategyConfig.class)
})
公共void setjaxbc配置(列表配置){
这是配置=配置;
}
公共列表getJaxBConfigurations(){
返回配置;
}
公共列表getConfigurations(){
列表响应=getConfigurationConfigs();
如果(响应==null){
响应=空的配置列表;
}
返回响应;
}

您是否解决了此问题?
private static final List<StrategyConfiguration<Transaction>> EMPTY_CONFIGURATION_LIST = Collections.emptyList();
private List<StrategyConfiguration<Transaction>> configurations;
@XmlElementWrapper(name = "boundaries")
@XmlElements({
    @XmlElement(name = "a", type = abtStrategyConfig.class),
    @XmlElement(name = "b", type = bbtStrategyConfig.class),
    @XmlElement(name = "c", type = cbtStrategyConfig.class)
})
public void setJaxBConfigurations(List<StrategyConfiguration<Transaction>> configurations) {
    this.configurations = configurations;
}
public List<StrategyConfiguration<Transaction>> getJaxBConfigurations() {
    return configurations;
}
public List<StrategyConfiguration<Transaction>> getConfigurations() {
    List<StrategyConfiguration<Transaction>> response = getConfigurationConfigs();
    if (response == null) {
        response = EMPTY_CONFIGURATION_LIST;
    }
    return response;
}