{"id":19285,"date":"2018-03-15T16:00:42","date_gmt":"2018-03-15T16:00:42","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=19285"},"modified":"2024-09-04T06:49:30","modified_gmt":"2024-09-04T06:49:30","slug":"how-to-fix-testng-by-default-disables-loading-dtd-from-unsecured-urls-error","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/how-to-fix-testng-by-default-disables-loading-dtd-from-unsecured-urls-error\/","title":{"rendered":"How to fix TestNG by default disables loading DTD from unsecured Urls error?"},"content":{"rendered":"<h2>How to fix TestNG by default disables loading DTD from unsecured Urls error?<\/h2>\n<p>TestNG by default disables loading DTD from unsecured Urls. If you need to explicitly load the DTD from a http url, please do so by using the JVM argument [-Dtestng.dtd.http=true].<\/p>\n<p>Indication of the error is failure to run the tests. Error stack trace displayed as shown below:<\/p>\n<h3>Error Trace<\/h3>\n<pre>org.testng.TestNGException: \r\nTestNG by default disables loading DTD from unsecured Urls. \r\nIf you need to explicitly load the DTD from a http url, please do so by\r\n using the JVM argument [-Dtestng.dtd.http=true]\r\n\tat org.testng.xml.TestNGContentHandler.resolveEntity\r\n(TestNGContentHandler.java:115)\r\n\tat java.xml\/com.sun.org.apache.xerces.internal\r\n.util.EntityResolverWrapper.resolveEntity(EntityResolverWrapper.java:111)\r\n\tat java.xml\/com.sun.org.apache.xerces.internal\r\n.impl.XMLEntityManager.resolveEntityAsPerStax(XMLEntityManager.java:1025)\r\n\tat java.xml\/com.sun.org.apache.xerces.internal\r\n.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1142)\r\n\tat java.xml\/com.sun.org.apache.xerces.internal\r\n.impl.XMLDocumentScannerImpl$DTDDriver.next(XMLDocumentScannerImpl.java:1040)\r\n\tat java.xml\/com.sun.org.apache.xerces.internal\r\n.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:943)\r\n\tat java.xml\/com.sun.org.apache.xerces.internal\r\n.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605)\r\n\tat java.xml\/com.sun.org.apache.xerces.internal\r\n.impl.XMLDocumentFragmentScannerImpl\r\n.scanDocument(XMLDocumentFragmentScannerImpl.java:541)\r\n\tat java.xml\/com.sun.org.apache.xerces.internal\r\n.parsers.XML11Configuration.parse(XML11Configuration.java:888)\r\n\tat java.xml\/com.sun.org.apache.xerces.internal\r\n.parsers.XML11Configuration.parse(XML11Configuration.java:824)\r\n\tat java.xml\/com.sun.org.apache.xerces.internal\r\n.parsers.XMLParser.parse(XMLParser.java:141)\r\n\tat java.xml\/com.sun.org.apache.xerces.internal\r\n.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1224)\r\n\tat java.xml\/com.sun.org.apache.xerces.internal\r\n.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:635)\r\n\tat java.xml\/com.sun.org.apache.xerces.internal\r\n.jaxp.SAXParserImpl.parse(SAXParserImpl.java:324)\r\n\tat java.xml\/javax.xml.parsers.SAXParser.parse(SAXParser.java:197)\r\n\tat org.testng.xml.XMLParser.parse(XMLParser.java:39)\r\n\tat org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:16)\r\n\tat org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:9)\r\n\tat org.testng.xml.Parser.parse(Parser.java:162)\r\n\tat org.testng.xml.Parser.parse(Parser.java:248)\r\n\tat org.testng.TestNG.parseSuite(TestNG.java:322)\r\n\tat org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:374)\r\n\tat org.testng.TestNG.initializeEverything(TestNG.java:1017)\r\n\tat org.testng.remote.support.RemoteTestNG6_12\r\n.initialize(RemoteTestNG6_12.java:22)\r\n\tat org.testng.remote.AbstractRemoteTestNG\r\n.run(AbstractRemoteTestNG.java:98)\r\n\tat org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)\r\n\tat org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)\r\n<\/pre>\n<h3>Root Cause<\/h3>\n<p>The main cause for the error is that we are pointing to insecure HTTP URL locations in the testng.xml file. For example DTD<\/p>\n<h3>Fix<\/h3>\n<p>The fix is to modify the http xml prologs, DTD links to secure HTTPS.\u00a0Example, change the DTD specification in the TestNG XML file:<\/p>\n<p><strong>http:\/\/testng.org\/testng-1.0.dtd\u00a0<\/strong><\/p>\n<p>Modify this to HTTPS link:<\/p>\n<p><strong>https:\/\/testng.org\/testng-1.0.dtd<\/strong><\/p>\n<p>Save the Test suite XML file.<\/p>\n<p>Re-run the tests.<\/p>\n<p>Alternatively, we can use the JVM argument hook [-Dtestng.dtd.http=true]. In the IDE<\/p>\n<p>Run &gt;&gt; Edit configuration we can add the JVM hook.<\/p>\n<p>TestNG Tutorials on this website can be found at:<\/p>\n<p><strong><a href=\"https:\/\/www.testingdocs.com\/testng-framework-tutorial\/\">https:\/\/www.testingdocs.com\/testng-framework-tutorial\/<\/a><\/strong><\/p>\n<p>For more details on the TestNG Framework, visit the official website of TestNG at:<\/p>\n<p><strong><a href=\"https:\/\/testng.org\" rel=\"noopener\">https:\/\/testng.org<\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to fix TestNG by default disables loading DTD from unsecured Urls error? TestNG by default disables loading DTD from unsecured Urls. If you need to explicitly load the DTD from a http url, please do so by using the JVM argument [-Dtestng.dtd.http=true]. Indication of the error is failure to run the tests. Error stack [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[213],"tags":[215],"class_list":["post-19285","post","type-post","status-publish","format-standard","hentry","category-testng","tag-testng-questions","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/19285","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=19285"}],"version-history":[{"count":8,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/19285\/revisions"}],"predecessor-version":[{"id":23991,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/19285\/revisions\/23991"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=19285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=19285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=19285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}