21

I'm trying to deploy a very simple HTTPServlet project using Tomcat 7 in my Eclipse J2EE perspective. I am getting the error "Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 and 6 Web modules". I have already tried modifying my org.eclipse.wst.common.project.facet.core.xml as mentioned here file but that doesn't seem to fix the issue. I'm able to deploy just fine by using file->export->.war directly to my installed tomcat server. Any ideas?

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
Jason
  • 1,371
  • 4
  • 21
  • 44

10 Answers10

30

Go to Project Properties -> Project Facets and change the version of Dynamic Web Module. If it is set to 3.1 then change it to 3.0. In case it does not allow you to change the version, uncheck it and press apply. Then you can select the version, check it and apply-OK. Worked for me!

Piyush Vashisht
  • 301
  • 3
  • 2
23

Yes, using Maven, Spring project with Java EE compliance we face this issue with Tomcat. To fix this problem please execute the list of commands to make the project as Java EE compliance.

  1. $ mvn eclipse:clean - to clean the eclipse files like .project .classpath
  2. $ mvn eclipse:eclipse -Dwtpversion=2.0 to create the eclipse compatible with Java EE.

At last open the project in eclipse select the server tomcat now click run on servers(Alt+Shift+x,R) select tomcat7.0 to run.

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
Pavan
  • 1,219
  • 13
  • 15
  • In my case, as a result of the execution of the two Maven commands, the Dynamic Web Module in my Project Facets was configured to version 2.4. The problem was still there until I changed the version to 3.0. – Yuci Jul 05 '16 at 11:32
  • Genius. Worked perfect. – GC_ Sep 11 '20 at 16:26
11

If you are getting "Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 and 6 Web modules" error when trying to add project to Tomcat 7. Simply,

Right click on the project --> go to project facets --> uncheck the dymanic web module (which should be 3.1)--> apply --> then change the dynamic web module to 3.0 --> apply and then save.

Try to add now and it should work.

ht_3535
  • 363
  • 3
  • 9
7

Tomcat is not a Java EE compliant application server, so you won't have EJB or CDI out-of-the-box here. Instead, use JBoss Wildfly or TomEE which are built on top of tomcat. Or, change to a complete different Java EE implementation like GlassFish.

Another option may be if you deploy directly into Tomcat. Eclipse by default deploys on a different folder and use some kind of bypass to see it deployed on Tomcat. Follow these steps:

  1. In your Eclipse, go to the Servers view (if it's not visible in the IDE, go to Window/Show view/Servers), it will show you your tomcat server (and others), double click on it.
  2. In the Tomcat overview window, check the Server locations panel, expand it and check where the webapp is deployed.
  3. If selected option is Use Tomcat installation then the web app must be in <tomcat>/webapps. If not, make sure to select this option and the application will be directly deployed on Tomcat folder.
Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
  • The server works perfectly fine with the application when deployed directly to the Tomcat/webapps folder. I only see this problem in Eclipse while trying to add to the server instance in my J2EE perspective. Also, I have other JAX-RS projects that I can add with no issues through the same J2EE perspective – Jason Aug 01 '14 at 20:07
  • Not too sure what the root of my problem was but I created a copy of the project that was not working and then was able to add it to my server. However, I also was messing around with the "Server Locations settings" so that might have been the culprit. Ultimatly I am able to deploy my project dynamically after switching to "Use Tomcat installation" option so will accept your answer :) thanks! – Jason Aug 01 '14 at 20:51
  • @PhilipRego and that's because...? – Luiggi Mendoza Sep 29 '17 at 00:47
  • Check your web.xml file and see which Servlet version you're using. Make sure it's 3.0. Also, check the properties for your project and make sure it works with Web 3.0, not higher. – Luiggi Mendoza Sep 29 '17 at 00:51
7

For Tomcat Version 6

In project, .settings folder OR Or CTRL+SHIFT+R : find this file

org.eclipse.wst.common.project.facet.core.xml

change the version of facet=jst.web to 2.4 or 2.5

File : org.eclipse.wst.common.project.facet.core.xml

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
  <fixed facet="jst.java"/>
  <fixed facet="jst.web"/>
  <installed facet="jst.web" version="2.4"/>
  <installed facet="jst.java" version="6.0"/>
</faceted-project>

Tomcat 7 You need facet="jst.web" version="3.0" to deploy on Tomcat 7.

Ankit Pandey
  • 1,790
  • 1
  • 19
  • 22
5

To Solve this Issue You will have to update your Dynamic Web Module version from 3.1 to 3.0. Eclipse dosen't allow these updation directly via Build Path-->Configure Build Path-->Project Facets.

Follow these steps Open file : YourPrjectFolder/.setting/org.eclipse.wst.common.project.facet.core

  1. In project folder, goto .settings folder.
  2. Open org.eclipse.wst.common.project.facet.core XML document.
  3. Edit line <installed facet="jst.web" version="3.1"/> to <installed facet="jst.web" version="3.0"/>
  4. Save the changes.
  5. Goto Eclipse and refresh the project.

You will be able to publish the your project now on Tomcat 7.

darvycode
  • 51
  • 1
  • 2
4

1)Go to your project on folder in eclipse workspace.
2)Open the .setting folder
3)Open the "org.eclipse.wst.common.project.facet.core" xml file
4)Update the version in last line as 2.4 or 2.5
5)Refresh the project and try to run on server

ggwp
  • 51
  • 6
1

This problem can be resolved by by changing the Dynamic Web Module version to 3.0. This can be done in 2 ways.

  1. Goto project properties and click on project facets, now you see the option Dynamic Web Module, change it to 3.0

  2. For those who can't change the version in the above step, open org.eclipse.wst.common.project.facet.core.xml and change the version here to something like <installed facet="jst.web" version="3.0"/>

Now go to project facets and see the Dynamic Web Module version changed to 3.0

Suresh
  • 1,491
  • 2
  • 22
  • 27
0

I thought I'd add something to this question as I tried all of the above and ended up doing something different to fix my issue of:

Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 and 6 Web modules

which then also led to

Cannot change version of project facet Dynamic Web Module to version 3.0

In our project we are using Maven to build a Java 1.8 / Tomcat 8.5 application (which only supports Dynamic Web Module Version 3.0 - not 4.0)

Someone in our team made the following change in our parent pom.xml

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

The version had been moved from 3.0.1 to 4.0.0 and no-matter how many times I tried to manually overwrite org.eclipse.wst.common.project.facet.core.xml with the right version <installed facet="jst.web" version="3.0"/> a Maven update re-over-wrote it with 4.0.

I set the version back to 3.0.1 as shown below and since then my Project Facets are showing the correct version, my apps are deploying to my internal Tomcat Server and to to this day, no-one is owning up to making the update to version 4.0.0 :)

<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>javax.servlet-api</artifactId>
  <version>3.0.1</version>
  <scope>provided</scope>
</dependency>
thonnor
  • 1,206
  • 2
  • 14
  • 28
0

For Tomcat 8.5 if you are facing this issue, change your facet setting to 3.1

Open file : {project_Folder}/.setting/org.eclipse.wst.common.project.facet.core

Open org.eclipse.wst.common.project.facet.core XML file. Change to version as 3.1 Save and refresh the project you will find it you can add the resource to tomcat.

This worked for me.. Thanks