Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Regression: Problem with new line for String param in client WS (JDK8 141 OK, JDK 161 ERROR) #1209

Open
matejsp opened this issue Jan 28, 2018 · 10 comments

Comments

@matejsp
Copy link

matejsp commented Jan 28, 2018

There is a new regression based on the latest release of JDK.
I have reproduced the problem using non JDK version of JAX-WS (version 2.3.0:

	<dependency>
		<groupId>com.sun.xml.ws</groupId>
		<artifactId>rt</artifactId>
		<version>2.3.0</version>
	</dependency>

The problem visible only when using combination of client WS and SoapHandler.
It fails with message "Entity References are not allowed in SOAP documents" where the reference is "#xd" inside createEntityReference method call. It seems that new lines are now escaped (#xd or #0a).
And this seems to bug createEntityReference logic.

Example:

	// use any WSDL based service/port
	BindingProvider bp = (BindingProvider) service;
	Map<String, Object> ctx = bp.getRequestContext();

	List<Handler> handlerChain = bp.getBinding().getHandlerChain();
	handlerChain.add(new SOAPHandler<SOAPMessageContext>() {

		@Override
		public boolean handleMessage(SOAPMessageContext context) {
			SOAPMessage msg = context.getMessage(); // --> CRASH
			// do something with msg (like logging)
			return true;
		}

		@Override
		public boolean handleFault(SOAPMessageContext context) {
			return true;
		}

		@Override
		public void close(MessageContext context) {
		}

		@Override
		public Set<QName> getHeaders() {
			return null;
		}
		
	});
	bp.getBinding().setHandlerChain(handlerChain);

	// WORKS
	service.echo("AABB");
	// DOES NOT WORK
	service.echo("AAr\r\nBB");

Stacktrace:

javax.xml.ws.WebServiceException: java.lang.UnsupportedOperationException: Entity References are not allowed in SOAP documents
	at com.sun.xml.ws.handler.ClientSOAPHandlerTube.callHandlersOnRequest(ClientSOAPHandlerTube.java:150)
	at com.sun.xml.ws.handler.HandlerTube.processRequest(HandlerTube.java:127)
	at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
	at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
	at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
	at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
	at com.sun.xml.ws.client.Stub.process(Stub.java:463)
	at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:191)
	at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
	at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:92)
	at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:161)
	at com.sun.proxy.$Proxy34.getCreditPaymentsSummary(Unknown Source)
	at com.halcom.ebp.services.loans.TestWS.test(TestWS.java:41)
	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.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Caused by: java.lang.UnsupportedOperationException: Entity References are not allowed in SOAP documents
	at com.sun.xml.messaging.saaj.soap.SOAPDocumentImpl.createEntityReference(SOAPDocumentImpl.java:221)
	at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.createEntityReference(SOAPPartImpl.java:515)
	at com.sun.xml.ws.api.message.saaj.SaajStaxWriter.writeEntityRef(SaajStaxWriter.java:267)
	at com.sun.xml.bind.v2.runtime.output.XMLStreamWriterOutput$XmlStreamOutWriterAdapter.writeEntityRef(XMLStreamWriterOutput.java:291)
	at com.sun.xml.bind.v2.runtime.output.XMLStreamWriterOutput$NewLineEscapeHandler.escape(XMLStreamWriterOutput.java:255)
	at com.sun.xml.bind.v2.runtime.output.XMLStreamWriterOutput.text(XMLStreamWriterOutput.java:165)
	at com.sun.xml.bind.v2.runtime.XMLSerializer.leafElement(XMLSerializer.java:328)
	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1070)
	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1049)
	at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(TransducedAccessor.java:254)
	at com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:130)
	at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:360)
	at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:696)
	at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:276)
	at com.sun.xml.bind.v2.runtime.BridgeImpl.marshal(BridgeImpl.java:94)
	at com.sun.xml.bind.api.Bridge.marshal(Bridge.java:111)
	at com.sun.xml.ws.db.glassfish.BridgeWrapper.marshal(BridgeWrapper.java:192)
	at com.sun.xml.ws.message.jaxb.JAXBMessage.writePayloadTo(JAXBMessage.java:417)
	at com.sun.xml.ws.message.AbstractMessageImpl.writeTo(AbstractMessageImpl.java:192)
	at com.sun.xml.ws.api.message.MessageWrapper.writeTo(MessageWrapper.java:226)
	at com.sun.xml.ws.api.message.saaj.SAAJFactory.readAsSOAPMessage(SAAJFactory.java:295)
	at com.sun.xml.ws.api.message.saaj.SAAJFactory.readAsSAAJ(SAAJFactory.java:222)
	at com.sun.xml.ws.api.message.saaj.SAAJFactory.read(SAAJFactory.java:211)
	at com.sun.xml.ws.message.AbstractMessageImpl.toSAAJ(AbstractMessageImpl.java:236)
	at com.sun.xml.ws.api.message.MessageWrapper.readAsSOAPMessage(MessageWrapper.java:176)
	at com.sun.xml.ws.handler.SOAPMessageContextImpl.getMessage(SOAPMessageContextImpl.java:85)
	at com.halcom.communicator.WsLoggingHandler.logContent(WsLoggingHandler.java:94)
	at com.halcom.communicator.WsLoggingHandler.handleMessage(WsLoggingHandler.java:45)
	at com.halcom.communicator.WsLoggingHandler.handleMessage(WsLoggingHandler.java:1)
	at com.sun.xml.ws.handler.HandlerProcessor.callHandleMessage(HandlerProcessor.java:297)
	at com.sun.xml.ws.handler.HandlerProcessor.callHandlersRequest(HandlerProcessor.java:138)
	at com.sun.xml.ws.handler.ClientSOAPHandlerTube.callHandlersOnRequest(ClientSOAPHandlerTube.java:142)
	... 35 more
@boufnichel
Copy link

Hello Guys,

Any update about this issue ?

@AlekseiEfimov
Copy link

JDK bug for tracking the same issue: https://bugs.openjdk.java.net/browse/JDK-8196491

@boufnichel
Copy link

Yes, at the moment i have disable my saop handlers...

@AlekseiEfimov
Copy link

AlekseiEfimov commented Apr 23, 2018

JDK-8196491 bug has been resolved in jdk8u-dev. Standalone fixes for JAXWS-RI and JAXB-RI have been delivered through these changesets:
JAXWS-RI part: 5a06cb2
JAXB-RI part: javaee/jaxb-v2@8f1e74a

I guess that this issue can be closed now

@Stexxen
Copy link

Stexxen commented Apr 23, 2018

Fix is expected to be included in Version 8u192.
Expected release date : October 2018

So no progression beyond 8u151, unless they backport it

@transentia
Copy link

I see this with standalone JAX-WS RI 2.3.0 as downloaded via Maven and JDK9 (eg zulu9.0.7.1-jdk9.0.7-win_x64). My codebase now relies on Java9 features and I can't move it back.

So: is this fix slated to be released in a (still useable from jdk9) JAX-WS RI 2.3.1 any time soon?

BTW: I tried compiling my own release locally but failed pretty miserably (undefined references to com.sun...internal classes, for example; couldn't find any build instructions anywhere...)

I'm looking to having to sanitise all my data manually (field-by-field) and this 'solution' is rather unappealing...

@harshpatel991
Copy link

@transentia can you post how you were able to pull in JAX-WS as a maven dependency?

@transentia
Copy link

I'm pulling in dependencies from mavenCentral in Gradle:

repositories {
    mavenCentral()
}

…

// https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api
implementation group: 'javax.xml.ws', name: 'jaxws-api', version: '2.3.0'

implementation 'org.jvnet.jax-ws-commons.spring:jaxws-spring:1.9'

// https://mvnrepository.com/artifact/com.sun.xml.ws/jaxws-rt
implementation group: 'com.sun.xml.ws', name: 'jaxws-rt', version: '2.3.0', ext: 'pom'

@boufnichel
Copy link

it's fixed on the 1_8_172 (check release note here : http://www.oracle.com/technetwork/java/javaseproducts/documentation/8u172-revision-builds-relnotes-4465508.html )

@transentia
Copy link

Thanks for that.

Is there a timeline for the standalone release? As I said, I have moved to JDK 9 features and can't go back, so the standalone is the only option for me...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants