Java and Xerces: can't find property XMLConstants.ACCESS_EXTERNAL_DTD
I looked for similar posts on this blog, but couldn't find an answer to my question, so I decided to ask for help.
I wrote this simple function in Java:
public void open(InputStream stream) throws FoliumFatalException {
try {
InputSource is = new InputSource(stream);
DocumentBuilderFactory dfact = DocumentBuilderFactory.newInstance();
// /* OWASP: inhibit access to External Entities */
dfact.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
dfact.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
_doc = dfact.newDocumentBuilder().parse(is);
} catch (Throwable t) {
_logger.error(t, t);
throw new FoliumFatalException("ENG-0017", "Errore di parsing su stream", t);
}
}
My goal is applying OWASP standards as exposed here, but I get the following error:
java.lang.IllegalArgumentException: Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.
java.lang.IllegalArgumentException: Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.
at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.setAttribute(Unknown Source) ~[xercesImpl-2.8.0.jar:?]
at agora.folium.engine.impl.j2ee.FoliumJ2eeXmlParserImpl.open(FoliumJ2eeXmlParserImpl.java:108) [classes/:?]
at agora.folium.engine.impl.FoliumAbstractEngine.loadServices(FoliumAbstractEngine.java:268) [classes/:?]
at agora.folium.engine.impl.j2ee.FoliumJ2eeEngineImpl.startup(FoliumJ2eeEngineImpl.java:110) [classes/:?]
at agora.folium.engine.Folium.startup(Folium.java:258) [classes/:?]
at agora.folium.control.impl.j2ee.FoliumActionServlet.init(FoliumActionServlet.java:94) [classes/:?]
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1230) [catalina.jar:7.0.85]
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1174) [catalina.jar:7.0.85]
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1066) [catalina.jar:7.0.85]
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5370) [catalina.jar:7.0.85]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5668) [catalina.jar:7.0.85]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) [catalina.jar:7.0.85]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1015) [catalina.jar:7.0.85]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:991) [catalina.jar:7.0.85]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652) [catalina.jar:7.0.85]
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:712) [catalina.jar:7.0.85]
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:2002) [catalina.jar:7.0.85]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_141]
at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_141]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_141]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_141]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_141]
I'm using Eclipse Oxygen, Tomcat 7 and Java 1.8.
Can anyone help me?
Thanks for your support.
java eclipse tomcat xerces
add a comment |
I looked for similar posts on this blog, but couldn't find an answer to my question, so I decided to ask for help.
I wrote this simple function in Java:
public void open(InputStream stream) throws FoliumFatalException {
try {
InputSource is = new InputSource(stream);
DocumentBuilderFactory dfact = DocumentBuilderFactory.newInstance();
// /* OWASP: inhibit access to External Entities */
dfact.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
dfact.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
_doc = dfact.newDocumentBuilder().parse(is);
} catch (Throwable t) {
_logger.error(t, t);
throw new FoliumFatalException("ENG-0017", "Errore di parsing su stream", t);
}
}
My goal is applying OWASP standards as exposed here, but I get the following error:
java.lang.IllegalArgumentException: Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.
java.lang.IllegalArgumentException: Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.
at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.setAttribute(Unknown Source) ~[xercesImpl-2.8.0.jar:?]
at agora.folium.engine.impl.j2ee.FoliumJ2eeXmlParserImpl.open(FoliumJ2eeXmlParserImpl.java:108) [classes/:?]
at agora.folium.engine.impl.FoliumAbstractEngine.loadServices(FoliumAbstractEngine.java:268) [classes/:?]
at agora.folium.engine.impl.j2ee.FoliumJ2eeEngineImpl.startup(FoliumJ2eeEngineImpl.java:110) [classes/:?]
at agora.folium.engine.Folium.startup(Folium.java:258) [classes/:?]
at agora.folium.control.impl.j2ee.FoliumActionServlet.init(FoliumActionServlet.java:94) [classes/:?]
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1230) [catalina.jar:7.0.85]
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1174) [catalina.jar:7.0.85]
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1066) [catalina.jar:7.0.85]
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5370) [catalina.jar:7.0.85]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5668) [catalina.jar:7.0.85]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) [catalina.jar:7.0.85]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1015) [catalina.jar:7.0.85]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:991) [catalina.jar:7.0.85]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652) [catalina.jar:7.0.85]
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:712) [catalina.jar:7.0.85]
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:2002) [catalina.jar:7.0.85]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_141]
at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_141]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_141]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_141]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_141]
I'm using Eclipse Oxygen, Tomcat 7 and Java 1.8.
Can anyone help me?
Thanks for your support.
java eclipse tomcat xerces
xercesImpl-2.8.0.jar:?
? Do you have a copy of Xerces in your web app?
– nitind
Nov 14 '18 at 16:03
yes, I have. I even tried to change priorities in Eclipse Build Path Section, using XercesImpl before JRE System Library.
– Bia
Nov 15 '18 at 11:54
That might work for a regular Java application, but Tomcat has to load classes from you web app's jars. Tricks like that won't work.
– nitind
Nov 16 '18 at 22:21
add a comment |
I looked for similar posts on this blog, but couldn't find an answer to my question, so I decided to ask for help.
I wrote this simple function in Java:
public void open(InputStream stream) throws FoliumFatalException {
try {
InputSource is = new InputSource(stream);
DocumentBuilderFactory dfact = DocumentBuilderFactory.newInstance();
// /* OWASP: inhibit access to External Entities */
dfact.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
dfact.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
_doc = dfact.newDocumentBuilder().parse(is);
} catch (Throwable t) {
_logger.error(t, t);
throw new FoliumFatalException("ENG-0017", "Errore di parsing su stream", t);
}
}
My goal is applying OWASP standards as exposed here, but I get the following error:
java.lang.IllegalArgumentException: Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.
java.lang.IllegalArgumentException: Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.
at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.setAttribute(Unknown Source) ~[xercesImpl-2.8.0.jar:?]
at agora.folium.engine.impl.j2ee.FoliumJ2eeXmlParserImpl.open(FoliumJ2eeXmlParserImpl.java:108) [classes/:?]
at agora.folium.engine.impl.FoliumAbstractEngine.loadServices(FoliumAbstractEngine.java:268) [classes/:?]
at agora.folium.engine.impl.j2ee.FoliumJ2eeEngineImpl.startup(FoliumJ2eeEngineImpl.java:110) [classes/:?]
at agora.folium.engine.Folium.startup(Folium.java:258) [classes/:?]
at agora.folium.control.impl.j2ee.FoliumActionServlet.init(FoliumActionServlet.java:94) [classes/:?]
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1230) [catalina.jar:7.0.85]
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1174) [catalina.jar:7.0.85]
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1066) [catalina.jar:7.0.85]
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5370) [catalina.jar:7.0.85]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5668) [catalina.jar:7.0.85]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) [catalina.jar:7.0.85]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1015) [catalina.jar:7.0.85]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:991) [catalina.jar:7.0.85]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652) [catalina.jar:7.0.85]
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:712) [catalina.jar:7.0.85]
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:2002) [catalina.jar:7.0.85]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_141]
at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_141]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_141]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_141]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_141]
I'm using Eclipse Oxygen, Tomcat 7 and Java 1.8.
Can anyone help me?
Thanks for your support.
java eclipse tomcat xerces
I looked for similar posts on this blog, but couldn't find an answer to my question, so I decided to ask for help.
I wrote this simple function in Java:
public void open(InputStream stream) throws FoliumFatalException {
try {
InputSource is = new InputSource(stream);
DocumentBuilderFactory dfact = DocumentBuilderFactory.newInstance();
// /* OWASP: inhibit access to External Entities */
dfact.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
dfact.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
_doc = dfact.newDocumentBuilder().parse(is);
} catch (Throwable t) {
_logger.error(t, t);
throw new FoliumFatalException("ENG-0017", "Errore di parsing su stream", t);
}
}
My goal is applying OWASP standards as exposed here, but I get the following error:
java.lang.IllegalArgumentException: Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.
java.lang.IllegalArgumentException: Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.
at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.setAttribute(Unknown Source) ~[xercesImpl-2.8.0.jar:?]
at agora.folium.engine.impl.j2ee.FoliumJ2eeXmlParserImpl.open(FoliumJ2eeXmlParserImpl.java:108) [classes/:?]
at agora.folium.engine.impl.FoliumAbstractEngine.loadServices(FoliumAbstractEngine.java:268) [classes/:?]
at agora.folium.engine.impl.j2ee.FoliumJ2eeEngineImpl.startup(FoliumJ2eeEngineImpl.java:110) [classes/:?]
at agora.folium.engine.Folium.startup(Folium.java:258) [classes/:?]
at agora.folium.control.impl.j2ee.FoliumActionServlet.init(FoliumActionServlet.java:94) [classes/:?]
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1230) [catalina.jar:7.0.85]
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1174) [catalina.jar:7.0.85]
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1066) [catalina.jar:7.0.85]
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5370) [catalina.jar:7.0.85]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5668) [catalina.jar:7.0.85]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) [catalina.jar:7.0.85]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1015) [catalina.jar:7.0.85]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:991) [catalina.jar:7.0.85]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652) [catalina.jar:7.0.85]
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:712) [catalina.jar:7.0.85]
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:2002) [catalina.jar:7.0.85]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_141]
at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_141]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_141]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_141]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_141]
I'm using Eclipse Oxygen, Tomcat 7 and Java 1.8.
Can anyone help me?
Thanks for your support.
java eclipse tomcat xerces
java eclipse tomcat xerces
asked Nov 14 '18 at 11:34
BiaBia
305
305
xercesImpl-2.8.0.jar:?
? Do you have a copy of Xerces in your web app?
– nitind
Nov 14 '18 at 16:03
yes, I have. I even tried to change priorities in Eclipse Build Path Section, using XercesImpl before JRE System Library.
– Bia
Nov 15 '18 at 11:54
That might work for a regular Java application, but Tomcat has to load classes from you web app's jars. Tricks like that won't work.
– nitind
Nov 16 '18 at 22:21
add a comment |
xercesImpl-2.8.0.jar:?
? Do you have a copy of Xerces in your web app?
– nitind
Nov 14 '18 at 16:03
yes, I have. I even tried to change priorities in Eclipse Build Path Section, using XercesImpl before JRE System Library.
– Bia
Nov 15 '18 at 11:54
That might work for a regular Java application, but Tomcat has to load classes from you web app's jars. Tricks like that won't work.
– nitind
Nov 16 '18 at 22:21
xercesImpl-2.8.0.jar:?
? Do you have a copy of Xerces in your web app?– nitind
Nov 14 '18 at 16:03
xercesImpl-2.8.0.jar:?
? Do you have a copy of Xerces in your web app?– nitind
Nov 14 '18 at 16:03
yes, I have. I even tried to change priorities in Eclipse Build Path Section, using XercesImpl before JRE System Library.
– Bia
Nov 15 '18 at 11:54
yes, I have. I even tried to change priorities in Eclipse Build Path Section, using XercesImpl before JRE System Library.
– Bia
Nov 15 '18 at 11:54
That might work for a regular Java application, but Tomcat has to load classes from you web app's jars. Tricks like that won't work.
– nitind
Nov 16 '18 at 22:21
That might work for a regular Java application, but Tomcat has to load classes from you web app's jars. Tricks like that won't work.
– nitind
Nov 16 '18 at 22:21
add a comment |
1 Answer
1
active
oldest
votes
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. To block access to external entities, you could write an EntityResolver (that always throws a SAXException) and register that EntityResolver with the DocumentBuilder. See documentation here [1].
[1] http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/parsers/DocumentBuilder.html#setEntityResolver(org.xml.sax.EntityResolver)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299280%2fjava-and-xerces-cant-find-property-xmlconstants-access-external-dtd%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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. To block access to external entities, you could write an EntityResolver (that always throws a SAXException) and register that EntityResolver with the DocumentBuilder. See documentation here [1].
[1] http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/parsers/DocumentBuilder.html#setEntityResolver(org.xml.sax.EntityResolver)
add a comment |
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. To block access to external entities, you could write an EntityResolver (that always throws a SAXException) and register that EntityResolver with the DocumentBuilder. See documentation here [1].
[1] http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/parsers/DocumentBuilder.html#setEntityResolver(org.xml.sax.EntityResolver)
add a comment |
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. To block access to external entities, you could write an EntityResolver (that always throws a SAXException) and register that EntityResolver with the DocumentBuilder. See documentation here [1].
[1] http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/parsers/DocumentBuilder.html#setEntityResolver(org.xml.sax.EntityResolver)
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. To block access to external entities, you could write an EntityResolver (that always throws a SAXException) and register that EntityResolver with the DocumentBuilder. See documentation here [1].
[1] http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/parsers/DocumentBuilder.html#setEntityResolver(org.xml.sax.EntityResolver)
answered Nov 23 '18 at 20:11
Michael GlavassevichMichael Glavassevich
88037
88037
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299280%2fjava-and-xerces-cant-find-property-xmlconstants-access-external-dtd%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
xercesImpl-2.8.0.jar:?
? Do you have a copy of Xerces in your web app?– nitind
Nov 14 '18 at 16:03
yes, I have. I even tried to change priorities in Eclipse Build Path Section, using XercesImpl before JRE System Library.
– Bia
Nov 15 '18 at 11:54
That might work for a regular Java application, but Tomcat has to load classes from you web app's jars. Tricks like that won't work.
– nitind
Nov 16 '18 at 22:21