Simplest SOAP Test doen't work in KS v8.0.x, Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized due to "accessExternalDTD

macOS 11.4 Big Sur

Katalon Studio Version

8.0.1

Katalon Studio logs

.log.zip (2.0 KB)

What I found

This seems to be an known issue to Katalon Team. I report it here again just to share information to those who newly encounter the problem.

I created a simplest SOAP API test project. A ZIP of the project is attached:

SimplestSOAP-API-Test.zip (104.5 KB)

I executed the Test Case “CalculatorTest”

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.testobject.ResponseObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS

ResponseObject response = WS.sendRequest(findTestObject('Calculator'), FailureHandling.CONTINUE_ON_FAILURE)

WS.verifyResponseStatusCode(response, 200)

String xmlString = response.getResponseBodyContent()
println(xmlString)

I got an Exception Stack trace:

2021-06-16 11:03:25.964 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2021-06-16 11:03:25.968 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/CalculatorTest
2021-06-16 11:03:27.137 DEBUG testcase.CalculatorTest                  - 1: response = sendRequest(findTestObject("Calculator"), CONTINUE_ON_FAILURE)
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
2021-06-16 11:03:28.616 INFO  c.k.k.core.webservice.common.HarLogger   - HAR: /var/folders/7m/lm7d6nx51kj0kbtnsskz6r3m0000gn/T/Katalon/Test Cases/CalculatorTest/20210616_110322/requests/main/0.har
2021-06-16 11:03:28.760 DEBUG testcase.CalculatorTest                  - 2: verifyResponseStatusCode(response, 200)
2021-06-16 11:03:28.789 DEBUG testcase.CalculatorTest                  - 3: xmlString = response.getResponseBodyContent()
2021-06-16 11:03:28.835 ERROR c.k.katalon.core.main.TestCaseExecutor   - ❌ Test Cases/CalculatorTest FAILED.
Reason:
java.lang.IllegalArgumentException: Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.
	at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.setAttribute(Unknown Source)
	at com.kms.katalon.util.DocumentBuilderProvider.newBuilderInstance(DocumentBuilderProvider.java:16)
	at com.kms.katalon.core.testobject.ResponseObject.getResponseBodyContent(ResponseObject.java:74)
	at com.kms.katalon.core.testobject.ResponseObject$getResponseBodyContent.call(Unknown Source)
	at CalculatorTest.run(CalculatorTest:11)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:398)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:389)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:368)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:360)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:255)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1623809002635.run(TempTestCase1623809002635.groovy:25)

2021-06-16 11:03:28.850 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/CalculatorTest

Here is the screenshot of Katalon Studio GUI when I got that error:

In the statck trace I found this line:

at com.kms.katalon.util.DocumentBuilderProvider.newBuilderInstance(DocumentBuilderProvider.java:16)

This message shows the exact location where the Exception was raised. I clicked the underlined DocumentBuilderProvier.java:16. Then Katalon Studio showed the source code of the class.

/*    */ public class DocumentBuilderProvider {
	/*    */ public static DocumentBuilder newBuilderInstance() throws ParserConfigurationException {
		/* 15 */ DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
		/* 16 */ dbFactory.setAttribute("http://javax.xml.XMLConstants/property/accessExternalDTD", "");
		/* 17 */ dbFactory.setAttribute("http://javax.xml.XMLConstants/property/accessExternalSchema", "");
		/* 18 */ return dbFactory.newDocumentBuilder();
		/*    */ }
	/*    */ }

This decompiled source code tells us that the com.kms.katalon.util.DocumentBuilderProvider class of KS v8.0.1 calls

/* 16 */ dbFactory.setAttribute("http://javax.xml.XMLConstants/property/accessExternalDTD", "");

This very statement is causing the `IllegalArgumentException: Property '“http://javax.xml.XMLConstants/property/accessExternalDTD” is not recognized.

In v 7.9.1

I tried the same in Katalon Studio v7.9.1. No exception was raised.

What I guess

The problematic statement:

/* 16 */ dbFactory.setAttribute("http://javax.xml.XMLConstants/property/accessExternalDTD", "");

I guess, this statement has been newly inserted in the KS v8.0.x. For what? I don’t know.
I guess, this statement was not there in the KS 7.9.0.
This is the reason why we see this exception only since KS v8.0.x.

Additional info

The sample project has a Test Case named “printXercesJarLocation”.

import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl

URL u = DocumentBuilderFactoryImpl.class.getResource("/" + DocumentBuilderFactoryImpl.class.getName().replaceAll("\\.", "/") + ".class");

System.out.println(u);

When I ran it i got the following output.

jar:file:/Applications/Katalon%20Studio.app/Contents/Eclipse/plugins/org.codehaus.groovy_2.4.20.v202009301404-e2006-RELEASE/lib/org.apache.xerces.impl_2.11.0.jar!/org/apache/xerces/jaxp/DocumentBuilderFactoryImpl.class

This proves that Katalon Studio 8.0.1 bundles the org.apache.xerces.impl_2.11.0.jar; which was released Feb, 2013.

According to this post on Stackoverflow,

Apache Xerces-J 2.12.0 and earlier implement older versions of JAXP that do not support either of the properties that you are trying to set.

My conclusion

So, I guess Katalon Team has made a mistake at v8.0.1, at com.kms.katalon.util.DocumentBuilderProvider class. Due to it, Katalon Studio v8.0.x can not process SOAP request/response messages and other XML documents appropriately.

But, if user’s Test Case and Keywords process XML documents without calling the problematic com.kms.katalon.util.DocumentBuilderProvider class, it will work fine.

-> @ThanhTo, @duyluong

Using v7.9.1, I checked if this class is available or not. See the following screenshot.

This check proved that the com.kms.katalon.util.DocumentBuilderProvider was newly introduced as of v8.0.x. This is the reason why we see the IllegalArgumentException in the v8.0.1 and do not see it in the v7.9.1.