Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.7.6, 1.7.9
-
None
-
None
-
Patch
Description
Hello devs,
after upgrading my webservice implementation on server and client from version 1.6.0 to 1.7.9 there have been several issues.
However I could solve all of them by updating my Axis2 configuration.
Except for one.
Transfering binary data to the client always triggered an exception on the client:
Failed to fetch the MIME part content org.apache.axiom.om.OMException: Failed to fetch the MIME part content at org.apache.axiom.attachments.PartImpl.fetch(PartImpl.java:201) at org.apache.axiom.attachments.PartImpl.getContent(PartImpl.java:152) at org.apache.axiom.attachments.PartImpl.getInputStream(PartImpl.java:248) at org.apache.axiom.attachments.PartDataSource.getInputStream(PartDataSource.java:44) at javax.activation.DataHandler.getInputStream(DataHandler.java:238) at com.icoserve.ws.va26.dms.ExportTest.exportDicomImage(ExportTest.java:49) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164) at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56) at java.lang.Thread.run(Thread.java:748) Caused by: java.io.IOException: Attempted read on closed stream. at org.apache.http.conn.EofSensorInputStream.isReadAllowed(EofSensorInputStream.java:107) at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:133) at java.io.FilterInputStream.read(FilterInputStream.java:133) at org.apache.axiom.om.util.DetachableInputStream.read(DetachableInputStream.java:147) at org.apache.james.mime4j.io.BufferedLineReaderInputStream.fillBuffer(BufferedLineReaderInputStream.java:111) at org.apache.james.mime4j.io.MimeBoundaryInputStream.fillBuffer(MimeBoundaryInputStream.java:223) at org.apache.james.mime4j.io.MimeBoundaryInputStream.read(MimeBoundaryInputStream.java:157) at org.apache.james.mime4j.io.BufferedLineReaderInputStream.fillBuffer(BufferedLineReaderInputStream.java:111) at org.apache.james.mime4j.io.BufferedLineReaderInputStream.read(BufferedLineReaderInputStream.java:158) at org.apache.james.mime4j.io.LineReaderInputStreamAdaptor.read(LineReaderInputStreamAdaptor.java:67) at org.apache.axiom.blob.MemoryBlobOutputStream.readFrom(MemoryBlobOutputStream.java:78) at org.apache.axiom.blob.MemoryBlobImpl.readFrom(MemoryBlobImpl.java:64) at org.apache.axiom.attachments.PartImpl.fetch(PartImpl.java:198) ... 52 more
After debugging a lot and reading the linked threads/issues, no solution mentioned there worked.
Thankfully a colleague had already found a solution for the problem.
The generated code did always close the stream before reading the linked resource due to MTOM.
His solution was to update the
/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl codegeneration template by adding this line at the end of line 453:
// add at end of line 453 // /org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl _returnEnv.buildWithAttachments();
Since I've changed the template from
// old
org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope();
to
// new
org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope(); _returnEnv.buildWithAttachments();
and re-generated the stubs, everything is working fine.
It would be really helpful for a lot of people to have the template be fixed for the next release.
The fix might also solve these issues:
https://issues.apache.org/jira/browse/AXIS2-5487
https://issues.apache.org/jira/browse/AXIS2-5967
https://issues.apache.org/jira/browse/HTTPCLIENT-910