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

Viewed 8569

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 ?
2 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.

Related