amazon-pay-sdk-java
amazon-pay-sdk-java copied to clipboard
IllegalArgumentException because of accessExternalDTD not supported on the Parser
Hi!
After the last commit on src/com/amazon/pay/impl/PayLogUtil.java (Line 128)
it generates a IllegalArgumentException calling the com.amazon.pay.response.parser.Parser methods, probably because there the accessExternalDTD has been set as not supported:
Stacktrace:
java.lang.IllegalArgumentException: Not supported: http://javax.xml.XMLConstants/property/accessExternalDTD at org.apache.xalan.processor.TransformerFactoryImpl.setAttribute(TransformerFactoryImpl.java:571) at com.amazon.pay.impl.PayLogUtil.getSanitizedData(PayLogUtil.java:126) at com.amazon.pay.impl.PayLogUtil.sanitizeString(PayLogUtil.java:75) at com.amazon.pay.response.parser.ResponseData.<init>(ResponseData.java:36) at com.amazon.pay.response.parser.GetOrderReferenceDetailsResponseData.<init>(GetOrderReferenceDetailsResponseData.java:30) at com.amazon.pay.response.parser.Parser.getOrderReferenceDetails(Parser.java:61)
Can you share what version of Java you were running this against, and which XML parsing related jars/libraries you are using? The changes worked against our internal integration tests. I'll need to know more about your environment so that we can troubleshoot further.
I have same problems of this issues.
because TransformerFactory and Xalan Dependency Conflict so when try call some API can not working
※java version 11
We have seen this from the same update which was introduced in 3.6.4: https://github.com/amzn/amazon-pay-sdk-java/compare/3.6.2...3.6.4#diff-d6aa52c278cef70f54019b3ccbbec94e6985cf71dbd86e732d66f9dae9b8ac24R126-R127
We are using:
- JDK: Amazon Corretto v11
-
amazon-pay-java-sdk
v3.7.1
The solution we have settled on is by overriding the TransformerFactory
class:
https://www.google.com/url?sa=j&url=https%3A%2F%2Fgithub.com%2Fguardian%2Fsupport-frontend%2Fpull%2F5355&uct=1697555454&usg=lbVWXUIxK4Zq4p3bIt-oEfjEWCE.&opi=82159412&source=chat
A Java style implementation of this can be seen here: https://stackoverflow.com/a/64364531
I do wonder, that given not all Transformers support this if there should be check or similar before setting these properties?