骆驼CXF:一种方式方案是访问用户主体,导致NULL指针异常



找到了WebSphere Liberty个人资料17.0.0.4的此问题。当我发出单程请求时,这将导致无效指针。它可以与请求响应服务一起工作。

我是一个春季启动应用程序。该代码可作为具有嵌入式tomcat容器的独立Springboot应用程序正常运行。

当在WebSphere Liberty配置文件中运行时,错误发生。我已禁用WLP中的嵌入式容器

部署
 java.lang.NullPointerException: null
    at com.ibm.ws.webcontainer.osgi.collaborator.CollaboratorHelperImpl.getCurrentSecurityCollaborator(CollaboratorHelperImpl.java:286) ~[na:na]
    at com.ibm.ws.webcontainer.srt.SRTServletRequest.getUserPrincipal(SRTServletRequest.java:2796) ~[na:na]
    at org.apache.cxf.transport.http.AbstractHTTPDestination$2.getUserPrincipal(AbstractHTTPDestination.java:392) ~[cxf-rt-transports-http-3.2.1.jar:3.2.1]
    at org.apache.camel.component.cxf.DefaultCxfBinding.populateExchangeFromCxfRequest(DefaultCxfBinding.java:274) ~[camel-cxf-2.20.1.jar:2.20.1]
    at org.apache.camel.component.cxf.CxfConsumer$CxfConsumerInvoker.prepareCamelExchange(CxfConsumer.java:316) ~[camel-cxf-2.20.1.jar:2.20.1]
    at org.apache.camel.component.cxf.CxfConsumer$CxfConsumerInvoker.syncInvoke(CxfConsumer.java:253) ~[camel-cxf-2.20.1.jar:2.20.1]
    at org.apache.camel.component.cxf.CxfConsumer$CxfConsumerInvoker.invoke(CxfConsumer.java:183) ~[camel-cxf-2.20.1.jar:2.20.1]
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59) ~[cxf-core-3.2.1.jar:3.2.1]

我通过覆盖defaultcxfbinding。CFX JMSCONFIG可以通过将"创建"为false创建creteSecurityContext来完成此操作。甚至HTTP传输也应该具有此功能

@Overridepublic void populateExchangeFromcxfRequest(Exchange cxfexchange,org.apache.camel.camel.exchange camelexchange){

Message cxfMessage = cxfExchange.getInMessage();    
cxfMessage.put(SecurityContext.class, null);        
super.populateExchangeFromCxfRequest(cxfExchange, camelExchange);

}

相关内容

  • 没有找到相关文章

最新更新