'bus properties settings ignored

I had cxf.xml file:

<beans ....

<cxf:bus>
    <cxf:features>
        <cxf:logging/>
    </cxf:features>
</cxf:bus>
</beans>

but during some operations, i got error:

org.apache.cxf.interceptor.Fault: Unmarshalling Error: Maximum Number of Child Elements limit (50000) Exceeded 

and I found out that it can be overridden with org.apache.cxf.stax.maxChildElements value. So i first tried putting org.apache.cxf.stax.maxChildElements=120000 in gradle, in IDEA arguments, which didnt work, so i modified my .xml file like this:

<cxf:bus>
    <cxf:features>
        <cxf:logging/>
    </cxf:features>
    <cxf:properties>
        <entry key="org.apache.cxf.stax.maxChildElements" value="120000"/>
    </cxf:properties>
</cxf:bus>

but none of this worked, and I am currently without ideas, as of why this setting is not getting registered.

Im working with libraries cxf-rt-frontend-jaxws and cxf-rt-transports-http both on version 3.2.7.



Solution 1:[1]

You can try doing configuration via java code as well.

You can get Bus instance which is used for creating your org.apache.cxf.endpoint.Client:

    YourActual service = //return instance of your @WebService class by defining address & interpreter;
    Client client=ClientProxy.getClient(service);
    client.getBus().setProperty(StaxUtils.MAX_CHILD_ELEMENTS,120000)

Or if you have your endpoint implementor then you can do :

Bus bus=BusFactory.getDefaultBus();
bus.setProperty(StaxUtils.MAX_CHILD_ELEMENTS,120000);

Object implementor = <Your service implementation class>;
EndpointImpl ep = (EndpointImpl) Endpoint.publish(yourendpoint, implementor);
ep.setBus(bus);

Above Bus configuration psudo-code taken from CXF doc.

Solution 2:[2]

If when you say "IDEA Arguments" you mean this box (labeled: Program Arguments)...

enter image description here

Try instead enabling Modify Options -> Add VM Options

enter image description here

Then write your VM Option string in the box labeled VM options. try

-Dorg.apache.cxf.stax.maxChildElements=1000000

enter image description here

This may or may not work depending on what you meant by IDEA Arguments. I have had IDEA ignore many options that I have tried to pass to the JVM via the "Program Arguments" box at work. Hopefully this resolves your issue. If this fails, I will try to monitor this thread.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Java-Enthusiast