2017-12-27 88 views
0

發現此問題與Websphere Liberty配置文件17.0.0.4。當我進行單向請求時,這會導致一個空指針。它適用於請求響應服務。駱駝CXF:單向場景訪問用戶主體導致空指針異常

礦是一個春季啓動應用程序。該代碼可以很好地作爲獨立的springboot應用程序與嵌入式tomcat容器一起運行。

在Websphere Liberty配置文件中運行時發生該錯誤。 whend在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] 

回答

0

部署我已經禁用了嵌入式容器我通過重寫DefaultCxfBinding.I已禁用SecurityContext的創建,現在解決了這個。 CFX JMSConfig可以通過將createSecurityContext設置爲false來做到這一點。即使是HTTP傳輸應該有這個功能

@覆蓋 公共無效populateExchangeFromCxfRequest(交易所cxfExchange,org.apache.camel.Exchange camelExchange){

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

}