CXF - Jaxws issue in Jboss AS 7: org.apache.cxf.staxutils.DepthExceededStaxException: reach the innerElementCountThreshold:50000

99封情书 提交于 2019-12-23 19:30:31

问题


I am facing an exception in Jaxws client while processing a SOAP webservice response, which is huge. This was working perfectly in Jboss 5.1. But I upgraded the Jboss to AS 7 and started getting below error.

Caused by: javax.xml.ws.soap.SOAPFaultException: reach the innerElementCountThreshold:50000
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:157)
    at com.sun.proxy.$Proxy41.getAllJobHistory(Unknown Source)
    at com.ep.service.impl.StatusSearchServiceImpl.findAll(StatusSearchServiceImpl.java:38) [classes:]
    at com.ep.controller.StatusBean.retrieveHistoryList(StatusBean.java:145) [classes:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_45]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_45]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_45]
    at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_45]
    at org.apache.el.parser.AstValue.invoke(AstValue.java:258) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
    at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68) [jsf-facelets-1.1.15.jar:1.1.15]
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jsf-api-1.2_15-b01-redhat-3.jar:1.2_15-b01-redhat-3]
    ... 31 more
Caused by: org.apache.cxf.staxutils.DepthExceededStaxException: reach the innerElementCountThreshold:50000
    at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1199)
    at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1129)
    at org.apache.cxf.binding.soap.saaj.SAAJInInterceptor.handleMessage(SAAJInInterceptor.java:223)
    at org.apache.cxf.jaxws.handler.soap.SOAPMessageContextImpl.getMessage(SOAPMessageContextImpl.java:78)
    at org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor.createProtocolMessageContext(SOAPHandlerInterceptor.java:257)
    at org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor.handleMessageInternal(SOAPHandlerInterceptor.java:161)
    at org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor.handleMessage(SOAPHandlerInterceptor.java:124)
    at org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor.handleMessage(SOAPHandlerInterceptor.java:71)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
    at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:800)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1704)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1537)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1445)
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:660)
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)

Is there a way to increase the response threshold in client initialization? I tried below logic and didn't work. Appreciate your help.

  BindingProvider.getRequestContext().put("org.apache.cxf.stax.maxChildElements", -1);

回答1:


I was running into a similar issue. There is a static method on the StaxUtils class (at least in the version I am using) to set the value for the innerElementCountThreshold. I added a call to StaxUtils.setInnerElementCountThreshold(-1) in my app's initialization code and the issue went away.




回答2:


Jboss AS 7 uses a new Apache CXF version which includes a better security policy, that performs this check to prevent attacks with very large soap response payloads.

I had the same problem, and I'm also using JAX-WS Handlers. The solutions where I used the BindingProvider or a org.apache.cxf.Bus didn't work because of the presence of my Jax-ws handlers.

It's a know issue: https://issues.apache.org/jira/browse/CXF-6173 However, the fix for this issue is in Apache CXF version 3.0.4, which is not included in a JBoss EAP version yet.

Therefore, I implemented a temporary fix, using the standalone.bat.conf file to set a system parameter. This is what I included in the standalone.bat.conf file:

set "JAVA_OPTS=%JAVA_OPTS% -Dorg.apache.cxf.stax.maxChildElements=10000000"

And it works fine.




回答3:


It is a static member and it seems the interceptor chain can be used to configure it. But, I am yet to find a efficient way to do it. Document says you can do it Bus or Endpoint level, but it just does'nt works for me.



来源:https://stackoverflow.com/questions/19416042/cxf-jaxws-issue-in-jboss-as-7-org-apache-cxf-staxutils-depthexceededstaxexcep

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!