Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.xml XMLConstants.FEATURE_SECURE_PROCESSING cannot resolve or not is a field

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:

enter image description here

Maven dependencies are:

enter image description here

enter image description here

enter image description here

Why don't I have the variable

XMLConstants.FEATURE_SECURE_PROCESSING ?
like image 600
Carlota Avatar asked Jul 04 '17 09:07

Carlota


People also ask

What is 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.

What is Access_external_dtd?

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.

What is the use of named constants in XML?

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.

What is accessExternalDTD?

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.


1 Answers

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:

  1. Right click on the project and select "Properties"
  2. Select "Java Build Path" from the left menu
  3. Select "Order and Export" tab
  4. Move "JRE System Library" on Top and Apply

In this way the Java libraries are used before the others.

like image 159
Ale Avatar answered Sep 20 '22 15:09

Ale