Eclipse Error: Dynamic Web Module 3.0 requires Java 1.6 or newer.

Problem: when creating maven project in eclipse, it always complains:
                          - Dynamic Web Module 3.0 requires Java 1.6 or newer.
             

Solution:
  1. In eclipse, find facets template file by name : org.eclipse.wst.common.project.facet.core.xml
  2. Edit the file and change the dynamic web module version in this line to 3.0 - <installed facet="jst.web" version="2.5"/>
  3.  <?xml version="1.0" encoding="UTF-8"?>  
     <faceted-project>  
      <fixed facet="wst.jsdt.web"/>  
      <installed facet="jst.web" version="3.0"/>  
      <installed facet="wst.jsdt.web" version="1.0"/>  
      <installed facet="java" version="1.8"/>  
     </faceted-project>  
    
  4. update web.xml to 3.0 dynamic web module as well. e.g
  5.  <web-app xmlns="http://java.sun.com/xml/ns/javaee"   
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   
                 http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"  
                 version="3.0">  
       <display-name>Servlet 3.0 Web Application</display-name>  
     </web-app>  
    
  6. in IDE(e.g eclipse), right click <project name> -> maven -> update projects.
  7. Done!

NOTE: if there is still error
Q: Dynamic Web Module 3.0 requires Java 1.6 or newer
A: add following in pom or compilation setting

      <build>  
           <directory>${basedir}/target</directory>  
           <plugins>  
                <plugin>  
                     <groupId>org.apache.maven.plugins</groupId>  
                     <artifactId>maven-compiler-plugin</artifactId>  
                     <version>3.3</version>  
                     <configuration>  
                          <source>1.8</source>  
                          <target>1.8</target>  
                          <showWarnings>true</showWarnings>  
                     </configuration>  
                </plugin>  
           </plugins>  
      </build>  

3 comments :