saaj 3.0.0 regression failure in MessageImpl.saveChanges()
Closed this issue · 3 comments
This change in code cleanup commit(0e12890) introduced the regression failure:
0e12890#diff-cf7fb3649d1c0e8b3a04257ca594c1094baf7ac25ff5cf29ef49b31ab6a3a473R84-R85
-
This happens with openjdk11 and xalan 2.7.2:
-
openjdk version "11.0.15" 2022-04-19
OpenJDK Runtime Environment Homebrew (build 11.0.15+0) -
xalan 2.7.2 https://github.com/apache/xalan-j/tree/xalan-j_2_7_2
From https://github.com/apache/xalan-j/blob/trunk/src/org/apache/xalan/processor/TransformerFactoryImpl.java#L507-L541,
these two attributes are not allowed :
tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
- Full error stacktrace:
java.lang.IllegalArgumentException: Not supported: http://javax.xml.XMLConstants/property/accessExternalDTD
at org.apache.xalan.processor.TransformerFactoryImpl.(TransformerFactoryImpl.java:571)
at com.sun.xml.messaging.saaj.util.transform.EfficientStreamingTransformer.<init>(EfficientStreamingTransformer.java:84)
at com.sun.xml.messaging.saaj.util.transform.EfficientStreamingTransformer.newTransformer(EfficientStreamingTransformer.java:419)
at com.sun.xml.messaging.saaj.soap.EnvelopeFactory.parseEnvelopeSax(EnvelopeFactory.java:180)
at com.sun.xml.messaging.saaj.soap.EnvelopeFactory.createEnvelope(EnvelopeFactory.java:95)
at com.sun.xml.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.createEnvelopeFromSource(SOAPPart1_1Impl.java:51)
at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:142)
at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.getContentAsStream(SOAPPartImpl.java:341)
at com.sun.xml.messaging.saaj.soap.MessageImpl.getHeaderBytes(MessageImpl.java:1094)
at com.sun.xml.messaging.saaj.soap.MessageImpl.saveChanges(MessageImpl.java:1246)
I am hitting this error as well, is there a workaround for this? Failing a real solution, I guess I can use @jimma's patch.
I made my own TransformerFactoryImpl and just ignored the attributes as a workaround.
public class TransformerFactoryImpl extends org.apache.xalan.processor.TransformerFactoryImpl {
/*
Workaround for issue https://github.com/eclipse-ee4j/metro-saaj/issues/205
*/
@Override
public void setAttribute(final String name, final Object value) throws IllegalArgumentException {
if(Objects.equals(name, "http://javax.xml.XMLConstants/property/accessExternalDTD")) {
return;
}
if(Objects.equals(name, "http://javax.xml.XMLConstants/property/accessExternalStylesheet")) {
return;
}
super.setAttribute(name, value);
}
}
Then set it like so:
System.setProperty("javax.xml.transform.TransformerFactory","ch.codeblock.ebill.sax.TransformerFactoryImpl");
Love your solution @SilvanJost.
I ended up just rolling back to 2.0.1, it works fine in my Java17 test environment, and there isn't anything in 3.x that I need.