cxf运行时异常未知客户端异常

f2uvfpb9  于 2021-07-09  发布在  Java
关注(0)|答案(1)|浏览(365)

我使用的是一个简单的mule流,它将springbean作为一个组件,并使用quartz端点定期执行它。我的cxf客户端和配置在我看来都很好,但是由于某些原因,我在尝试发送请求时遇到了一个异常。
我的班级如下:

  1. @Component
  2. @DependsOn("restfulClient")
  3. public class Transmitter implements Callable{
  4. private static final Logger logger =
  5. LoggerFactory.getLogger(Transmitter.class);
  6. @Autowired
  7. private RestfulClient restfulClient;
  8. public Object onCall(MuleEventContext eventContext) throws Exception {
  9. logger.info("In Transmitter");
  10. try {
  11. String result = restfulClient.ping();
  12. logger.info("Result: {}" , result);
  13. } catch (Exception e){
  14. logger.error("Exception in Transmitter" ,e);
  15. }
  16. return null;
  17. }
  18. }

我的委托人:

  1. @Produces({"text/plain"})
  2. @Path("/subscription")
  3. public interface RestfulClient {
  4. @GET
  5. @Path("/ping")
  6. public String ping();
  7. }

applicationContext.xml 我已经定义了cxf bean并启用了cxf日志记录:

  1. <jaxrs:client id="restfulClient"
  2. serviceClass="com.ws.RestfulClient"
  3. address="${prop.restful.url}">
  4. <jaxrs:features>
  5. <cxf:logging/>
  6. </jaxrs:features>
  7. </jaxrs:client>

url在中定义 application.properties 在调试模式下,它成功地构建了url。
当我尝试 Postman 的网址,它的工作很好,我得到 OK 但它在代码中不起作用。
我得到的例外是:

  1. java.lang.RuntimeException: Unknown client side exception
  2. at org.apache.cxf.jaxrs.client.AbstractClient.setResponseBuilder(AbstractClient.java:331)
  3. at org.apache.cxf.jaxrs.client.ClientProxyImpl.handleResponse(ClientProxyImpl.java:451)
  4. at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:445)
  5. at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:177)
  6. at com.sun.proxy.$Proxy27.ping(Unknown Source)
  7. at com.processor.Transmitter.onCall(Transmitter.java:77)
  8. at org.mule.model.resolvers.CallableEntryPointResolver.invoke(CallableEntryPointResolver.java:46)
  9. at org.mule.model.resolvers.DefaultEntryPointResolverSet.invoke(DefaultEntryPointResolverSet.java:36)
  10. at org.mule.component.DefaultComponentLifecycleAdapter.invoke(DefaultComponentLifecycleAdapter.java:339)
  11. at org.mule.component.AbstractJavaComponent.invokeComponentInstance(AbstractJavaComponent.java:82)
  12. at org.mule.component.AbstractJavaComponent.doInvoke(AbstractJavaComponent.java:73)
  13. at org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:122)
  14. at org.mule.component.AbstractComponent.access$000(AbstractComponent.java:57)
  15. at org.mule.component.AbstractComponent$1$1.process(AbstractComponent.java:238)
  16. at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
  17. at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
  18. at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
  19. at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:94)
  20. at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:67)
  21. at org.mule.processor.chain.InterceptingChainLifecycleWrapper.doProcess(InterceptingChainLifecycleWrapper.java:50)
  22. at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:67)
  23. at org.mule.processor.chain.InterceptingChainLifecycleWrapper.access$001(InterceptingChainLifecycleWrapper.java:22)
  24. at org.mule.processor.chain.InterceptingChainLifecycleWrapper$1.process(InterceptingChainLifecycleWrapper.java:66)
  25. at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
  26. at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
  27. at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
  28. at org.mule.processor.chain.InterceptingChainLifecycleWrapper.process(InterceptingChainLifecycleWrapper.java:61)
  29. at org.mule.component.AbstractComponent.process(AbstractComponent.java:156)
  30. at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
  31. at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
  32. at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
  33. at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:94)
  34. at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:67)
  35. at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
  36. at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
  37. at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:102)
  38. at org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:51)
  39. at org.mule.processor.AsyncInterceptingMessageProcessor.processNextTimed(AsyncInterceptingMessageProcessor.java:118)
  40. at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker$1.process(AsyncInterceptingMessageProcessor.java:189)
  41. at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker$1.process(AsyncInterceptingMessageProcessor.java:182)
  42. at org.mule.execution.ExecuteCallbackInterceptor.execute(ExecuteCallbackInterceptor.java:16)
  43. at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:30)
  44. at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:14)
  45. at org.mule.execution.BeginAndResolveTransactionInterceptor.execute(BeginAndResolveTransactionInterceptor.java:54)
  46. at org.mule.execution.ResolvePreviousTransactionInterceptor.execute(ResolvePreviousTransactionInterceptor.java:44)
  47. at org.mule.execution.SuspendXaTransactionInterceptor.execute(SuspendXaTransactionInterceptor.java:50)
  48. at org.mule.execution.ValidateTransactionalStateInterceptor.execute(ValidateTransactionalStateInterceptor.java:40)
  49. at org.mule.execution.IsolateCurrentTransactionInterceptor.execute(IsolateCurrentTransactionInterceptor.java:41)
  50. at org.mule.execution.ExternalTransactionInterceptor.execute(ExternalTransactionInterceptor.java:48)
  51. at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:28)
  52. at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:13)
  53. at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:109)
  54. at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:30)
  55. at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker.doRun(AsyncInterceptingMessageProcessor.java:181)
  56. at org.mule.work.AbstractMuleEventWork.run(AbstractMuleEventWork.java:39)
  57. at org.mule.work.WorkerContext.run(WorkerContext.java:286)
  58. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
  59. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
  60. at java.lang.Thread.run(Thread.java:745)
niknxzdl

niknxzdl1#

我发现了问题。问题出在

  1. <jaxrs:features>
  2. <cxf:logging/>
  3. </jaxrs:features>

属于格式错误的架构(老实说,我想知道为什么mule不给这样一个错误命名,而不是含糊不清的未知客户端异常!)

  1. <mule xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf
  2. <!-- -->
  3. http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
  4. http://www.mulesoft.org/schema/mule/cxf
  5. http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd" >

最后一个链接未找到。。

相关问题