2017-02-19 163 views
0

我試圖爲CXF服務指定超時。 我正在使用Play框架以及JAX-RS和CXF(我已經嘗試了多個版本,3.07和3.10)。異常嘗試設置CXF超時

這是我得到的異常:

 
2017-02-19 13:07:09,786 [error] - controllers.GPSWebServiceController - Error calling wsSanctionsPEPCheckV2 operation on GPS endpoint. 
java.util.concurrent.CompletionException: javax.xml.ws.soap.SOAPFaultException: Error creating bean with name '*.http-conduit': Cannot create inner bean '(inner bean)#741a1e82' of type [org.a 
pache.cxf.configuration.spring.JAXBBeanFactory] while setting bean property 'client'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with nam 
e '(inner bean)#741a1e82': Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.lang.Object]: Fa 
ctory method 'createJAXBBean' threw exception; nested exception is java.lang.RuntimeException: javax.xml.bind.UnmarshalException 
- with linked exception: 
[com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'h' (code 104) in start tag Expected a quote 
at [row,col {unknown-source}]: [1,35]] 
     at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273) 
     at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280) 
     at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1592) 
     at play.core.j.HttpExecutionContext$$anon$2.run(HttpExecutionContext.scala:56) 
     at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:39) 
     at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:405) 
     at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) 
     at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) 
     at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) 
     at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) 
Caused by: javax.xml.ws.soap.SOAPFaultException: Error creating bean with name '*.http-conduit': Cannot create inner bean '(inner bean)#741a1e82' of type [org.apache.cxf.configuration.spring. 
JAXBBeanFactory] while setting bean property 'client'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#741a1e82': Bean 
instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.lang.Object]: Factory method 'createJAXBBean' t 
hrew exception; nested exception is java.lang.RuntimeException: javax.xml.bind.UnmarshalException 
- with linked exception: 
[com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'h' (code 104) in start tag Expected a quote 
at [row,col {unknown-source}]: [1,35]] 
     at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:161) 
     at com.sun.proxy.$Proxy69.wsSanctionsPEPCheckV2(Unknown Source) 
     at services.pepcheck.PepCheckServiceImpl.lambda$performPepCheck$33(PepCheckServiceImpl.java:114) 
     at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590) 
     ... 7 common frames omitted 
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '*.http-conduit': Cannot create inner bean '(inner bean)#741a1e82' of type [org.apache.cxf.co 
nfiguration.spring.JAXBBeanFactory] while setting bean property 'client'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner be 
an)#741a1e82': Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.lang.Object]: Factory method 
'createJAXBBean' threw exception; nested exception is java.lang.RuntimeException: javax.xml.bind.UnmarshalException 
- with linked exception: 
[com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'h' (code 104) in start tag Expected a quote 
at [row,col {unknown-source}]: [1,35]] 
     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:313) 
     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:129) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1486) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1231) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.configureBean(AbstractAutowireCapableBeanFactory.java:323) 
     at org.springframework.beans.factory.wiring.BeanConfigurerSupport.configureBean(BeanConfigurerSupport.java:147) 
     at org.apache.cxf.configuration.spring.ConfigurerImpl.configureBean(ConfigurerImpl.java:177) 
     at org.apache.cxf.configuration.spring.ConfigurerImpl.configureWithWildCard(ConfigurerImpl.java:202) 

這是beans.xml的文件

<beans xmlns="http://www.springframework.org/schema/beans"                                  
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"                                 
     xmlns:jaxws="http://cxf.apache.org/jaxws"                                    
     xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"                             
     xmlns:cxf="http://cxf.apache.org/core"                                     
     xsi:schemaLocation="http://www.springframework.org/schema/beans                               
     http://www.springframework.org/schema/beans/spring-beans-4.3.xsd                               
     http://cxf.apache.org/configuration/security                                    
     http://cxf.apache.org/schemas/configuration/security.xsd                                 
     http://cxf.apache.org/transports/http/configuration                                  
     http://cxf.apache.org/schemas/configuration/http-conf.xsd                                 
     http://cxf.apache.org/core                                        
     http://cxf.apache.org/schemas/core.xsd                                     
     http://cxf.apache.org/jaxws                                        
     http://cxf.apache.org/schemas/jaxws.xsd">                                     


    <jaxws:client id="mySoapClient"                                      
        serviceClass="ro.vdin.ServiceSoap"                             
        address="https://example.com"/>                                    

    <http-conf:conduit name="*.http-conduit">                                     
     <http-conf:client ConnectionTimeout="60000"                                    
          ReceiveTimeout="60000"                                    
          AllowChunking="false"/>                                    
    </http-conf:conduit> 
</beans> 

我收到此消息僅如果HTTP-conf的:管道matches服務;如果我把一些隨機名稱放在一起,那麼我不會收到任何異常(但也不會超時)。

任何想法?

回答

0

在Play Framework上使用CXF時,我遇到了類似的問題。 我不知道爲什麼,但是你不能使用通配符*.http-conduit。您必須直接指定主機名:<http-conf:conduit name="https://example.com">

如果您有多個Web服務,則可以使用regexp來匹配所有這些服務。

例如:如果你有https://example.com/service1https://example.com/service2端點,配置將是<http-conf:conduit name="https://example.com/.*">

+0

感謝您的建議!不幸的是,我已經嘗試過,並且仍然收到相同的錯誤(例如;也嘗試使用正則表達式名稱=「https: //example.com:5678.*「和name =」https://example.com:5678/service.asmx.*「) –

+0

@VladDinulescu您是否嘗試添加協議?我想你必須指定它:'name =「https://example.com:5678/.*」'。也許這個問題不在http-conf:管道中。 'jaxws:client'' address'是否是'「https://example.com」'是否正常?它應該是完整的Web服務端點:'「https://example.com:5678/service.asmx」' –

+0

嗯......我確實添加了協議;我認爲StackOverflow格式化了我的評論,我沒有注意到。另外,關於jaxws:客戶端地址,是的,我放置了完整的Web服務端點,但由於隱私目的,我不想將它放在SO上。 (正如我在描述中所說的,我可以完全訪問服務,只是我無法正確設置超時)。 –