I work with Eclipse, Spring MVC and Maven.The Java version is 1.6
I have the following method
public static DocumentBuilder getBuilder(ServletContext servletContext)
{
DocumentBuilderFactory factory =DocumentBuilderFactory.newInstance();
factory.setValidating(true);
DocumentBuilder builder = null;
try {
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
builder = factory.newDocumentBuilder();
I have an error in the eclipse editor in the line:
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,
The error is
FEATURE_SECURE_PROCESSING cannot be resolved or not is a field
In the editor Eclipse I see:
Maven dependencies are:
Why don't I have the variable
XMLConstants.FEATURE_SECURE_PROCESSING ?
FEATURE_SECURE_PROCESSING. public static final String FEATURE_SECURE_PROCESSING. Feature for secure processing. true instructs the implementation to process XML securely. This may set limits on XML constructs to avoid conditions such as denial of service attacks.
public static final String ACCESS_EXTERNAL_DTD. Property: accessExternalDTD. Restrict access to external DTDs and external Entity References to the protocols specified. If access is denied due to the restriction of this property, a runtime exception that is specific to the context is thrown.
Constants. Prefix to use to represent the default XML Namespace. Feature for secure processing. Namespace URI to use to represent that there is no Namespace.
accessExternalDTD=all in jaxp. properties would allow a system to work as before with no restrictions on accessing external DTDs and Entity References. Denying any access: an empty string, that is, "", means no permission is granted to any protocol. For example, setting javax. xml.
I don't know if there is your case, but I solve the problem configuring the source folders in my Java project Build Path, following these steps:
In this way the Java libraries are used before the others.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With