相关文章推荐
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

AXIS Client 1.4 with JDK 8 gives org.apache.axis.AxisFault: java.util.ConcurrentModificationException

Ask Question

I am using AXIS (1.4) client to invoke SOAP web services and JDK version is 8. Getting following intermittent error for some of the SOAP service invocations. This is happening for 5-10 requests out of 1000 requests under load condition.

Caused by: org.apache.axis.AxisFault: java.util.ConcurrentModificationException
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:223) ~[axis-1.4.jar:na]
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:130) ~[axis-1.4.jar:na]
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1104) ~[axis-1.4.jar:na]
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) ~[na:na]
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source) ~[na:na]
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) ~[na:na]
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) ~[na:na]
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) ~[na:na]
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) ~[na:na]
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) ~[na:na]
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) ~[na:na]
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) ~[na:na]
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:241) ~[axis-1.4.jar:na]
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696) ~[axis-1.4.jar:na]
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435) ~[axis-1.4.jar:na]
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62) ~[axis-1.4.jar:na]
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206) ~[axis-1.4.jar:na]
at org.apache.axis.client.Call.invokeEngine(Call.java:2782) ~[axis-1.4.jar:na]
at org.apache.axis.client.Call.invoke(Call.java:2765) ~[axis-1.4.jar:na]
at org.apache.axis.client.Call.invoke(Call.java:2443) ~[axis-1.4.jar:na]
at org.apache.axis.client.Call.invoke(Call.java:2366) ~[axis-1.4.jar:na]
at org.apache.axis.client.Call.invoke(Call.java:1812) ~[axis-1.4.jar:na]
at com.te.prodirectory.services.client.PaymentWSSoapBindingStub.validateVamPayment(PaymentWSSoapBindingStub.java:423) ~[directory-qe-client-3.2.0-VAM2-RC24.jar:3.2.0-VAM2-RC24]
at com.te.prodirectory.services.payment.PaymentServiceWsImpl.validateVamPayment(PaymentServiceWsImpl.java:34) ~[directory-qe-client-3.2.0-VAM2-RC24.jar:3.2.0-VAM2-RC24]
... 37 common frames omitted

NOTE: When we used same AXIS client with JDK 7, did not face this issue at all.

I tried searching for similar issue of AXIS with JDK 8, there are some compatibility issues, but nothing like the one that I am facing currently.

Agree that https://issues.apache.org/jira/browse/AXIS-2909 seems to be the issue. Going back to jdk7 is usually not an option.

The suggestion in AXIS-2909 is to take latest 1.4.1-SNAPSHOT, from a successful jenkins build in 2017. This is coming from http://svn.apache.org/repos/asf/axis/axis1/java/trunk, and to put it short this trunk has undergone a lot of changes since 2006 (1.4), and is not officially released. - added maven support - completely restructured into maven modules - a lot of different changes, check svn log

veithen (A. Veithen) has done an excellent job within this trunk, and seems to be the maintainer.

A better approach, and safer, given you want only to fix the axis ConcurrentModificationException bug, and not introduce more changes than needed, can be to take the 1.4 tag, and apply patch on top of that.

https://svn.apache.org/repos/asf/axis/axis1/java/tags/1.4/

patch:

   // Convert to array before sorting to avoid concurrency issues
    OperationDesc[] array = (OperationDesc[])overloads.toArray(
        new OperationDesc[overloads.size()]);
    Arrays.sort(array,
        new Comparator() {
            public int compare(Object o1, Object o2)
                Method meth1 = ((OperationDesc)o1).getMethod();
                Method meth2 = ((OperationDesc)o2).getMethod();
                return (meth1.getParameterTypes().length -
                                     meth2.getParameterTypes().length);
    return array;

btw: AXIS-2875 is also needed, to make it compile with java8.

please note that this will be a time machine experience, as you are back in the ant build-script days. you will also need to incl j2ee-1.4.jar as compile-time lib. but then you are good to go, and can bake your own 1.4.1 containing +AXIS-2909

I followed this quick and dirty way to patch axis-1.4.jar using javac 1.8:

  • Download axis-1.4.jar from maven repository https://mvnrepository.com/artifact/org.apache.axis/axis/1.4
  • Download from maven axis-jaxrpc-1.4.jar and commons-logging-1.1.1.jar too

  • Copy JavaServiceDesc.java from original source code, to export them I used:
  • svn export https://svn.apache.org/repos/asf/axis/axis1/java/tags/1.4 axis-1.4

  • Edit the last lines of getOperationsByQName at line 527 in JavaServiceDesc.java as suggested by geewee

  • Compile using java 8:

    javac -d . -classpath axis-1.4.jar;axis-jaxrpc-1.4.jar;commons-logging-1.1.1.jar JavaServiceDesc.java

  • Update the original JAR file with the new class:

    jar uf axis-1.4.jar org\apache\axis\description\JavaServiceDesc.class org\apache\axis\description\JavaServiceDesc$1.class

    This worked well and solved the issue in my case.

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.

  •  
    推荐文章