Eclipse irreversible Dynamic Web Module 4.0 selection; Tomcat 9 doesn't support it

18,271

Solution 1

I reproduced the problem in the same environment as yours. When I tried to regress from 4.0 back to 3.1 I got the following error:

CannotDowngradeTo31

This blog provided the solution (which is a bit of a hack but it works):

  • Edit the file org.eclipse.wst.common.project.facet.core.xml in the project's .settings directory.
  • For the line containing facet="jst.web" version="4.0", change the version to 3.1.

Also see this SO question: Dynamic Web Module 3.0 -- 3.1


A couple of related issues:

  • It looks like something else may not be quite right with your setup to be getting that error "Tomcat version 9.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5, 6, 7, and 8 Web modules". Is your project configured to use Servlet 4.0? For my Maven project I had to add this dependency to the POM for Servlet 4.

  • Even after changing the Dynamic Web Module version to 3.1 my web app continued using version 4.0, so I'm not sure what that facet achieves.

Solution 2

For me, this issue went away after removing the dependency below from my pom file.

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>4.0.0</version>
    <scope>provided</scope>
</dependency>

hope that helps

Solution 3

My solution is a response to this message:

Dynamic Web Module 4.0 cannot be uninstalled.

1 - So; if you can't uninstall Dynamic Web Module (i repeat: "Uninstall" not "change its version"), You can first edit in your project directory the file: .settings/org.eclipse.wst.common.project.facet.core.xml and manually uninstall it by removing this line:

<installed facet="jst.web" version="4.0"/>

2 - After this, if you want to use dynamic web module 4.0, be sure that you use at least in your facets java 1.8 inside the same file .settings/org.eclipse.wst.common.project.facet.core.xml

<installed facet="java" version="1.8"/>

Or you can also change it in your "project Facets configuration" panel

3 - If the problem persist, take a look at your pom files and verify didn't force java version to 1.7, you should have these properties

    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>

Remember to update your project if you change your pom file: Maven > Update Projects

4 - Finally, if you still can't use Dynamic Web Module 4.0, juste choose between deleting your WEB-INF\web.xml file which can have a configuration for another dynamic web version like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
...

Otherwise you can manually change the supported version:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0">
...

return to the Project Facets configuration panel, a try once again to choose Dynamic Web Module 4.0, it should work

Hope this help.

Share:
18,271

Related videos on Youtube

Garret Wilson
Author by

Garret Wilson

Updated on June 04, 2022

Comments

  • Garret Wilson
    Garret Wilson almost 2 years

    I'm using Eclipse Oxygen.2 (4.7.2) on Windows 10 with Java 8. I have a faceted project I run inside Eclipse using Tomcat. I had been using Tomcat 8.5, but on a new system I upgraded to Tomcat 9. Of course I removed the Tomcat 8.5 server and server runtime within Eclipse, and added back a Tomcat 9 server runtime.

    Before adding the Tomcat 9 server within Eclipse I verified the Project Facets of my project. I saw that Dynamic Web Module was set to "3.1", but that now "4.0" was available. I changed to "4.0", figuring this would give me access to newer APIs.

    I then tried to add the Tomcat 9 server. During the process, at "Add and Remove" it asks me which projects I want to add to be configured for the server. I selected my web project, but Eclipse said: "Tomcat version 9.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5, 6, 7, and 8 Web modules".

    Now as far as I know that's exactly what I'm using. But the only thing I had changed was the Dynamic Web Module. So I went back to my project configuration and tried to change "Dynamic Web Module" back to "3.1". Eclipse tells me:

    Cannot change version of project facet Dynamic Web Module to 3.1.

    Um… so I'll just remove it. I unchecked the box next to "Dynamic Web Module", and Eclipse tells me:

    Dynamic Web Module 4.0 cannot be uninstalled.

    Well that's a fine kettle of fish. I can't deploy my project to Tomcat, apparently because of the Dynamic Web Module. I can't change the Dynamic Web Module back to what it was. What do I do? Where does the problem lie?

    I opened Eclipse Bug 530844 to see if I can get some reasons for this behavior.