Tomcat 7.0 版仅支持 J2EE 1.2、1.3、1.4 和 Java EE 5 和 6 Web 模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25087833/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 and 6 Web modules
提问by Jason
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 herefile 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?
我正在尝试在我的 Eclipse J2EE 透视图中使用 Tomcat 7 部署一个非常简单的 HTTPServlet 项目。我收到错误消息“Tomcat 7.0 版仅支持 J2EE 1.2、1.3、1.4 和 Java EE 5 和 6 Web 模块”。我已经尝试修改我的 org.eclipse.wst.common.project.facet.core.xml 如这里提到的文件,但这似乎并没有解决问题。通过将 file->export->.war 直接部署到我安装的 tomcat 服务器,我可以很好地部署。有任何想法吗?
采纳答案by Luiggi Mendoza
Tomcat is nota Java EE compliant application server, so you won't have EJB or CDI out-of-the-box here. Instead, use JBoss Wildflyor TomEEwhich are built on top of tomcat. Or, change to a complete different Java EE implementation like GlassFish.
Tomcat不是Java EE 兼容的应用程序服务器,因此您不会在此处使用现成的 EJB 或 CDI。相反,使用构建在 tomcat 之上的JBoss Wildfly或TomEE。或者,更改为完全不同的 Java EE 实现,例如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:
另一种选择可能是直接部署到 Tomcat 中。Eclipse 默认部署在不同的文件夹上,并使用某种绕过来查看它部署在 Tomcat 上。按着这些次序:
- 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.
- In the Tomcat overview window, check the Server locations panel, expand it and check where the webapp is deployed.
- 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.
- 在您的 Eclipse 中,转到 Servers 视图(如果它在 IDE 中不可见,请转到 Window/Show view/Servers),它会显示您的 tomcat 服务器(和其他服务器),双击它。
- 在 Tomcat 概览窗口中,检查服务器位置面板,将其展开并检查 web 应用程序的部署位置。
- 如果选择的选项是使用 Tomcat 安装,则 Web 应用程序必须位于
<tomcat>
/webapps 中。如果没有,请确保选择此选项,应用程序将直接部署在 Tomcat 文件夹中。
回答by Pavan
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.
是的,使用 Maven、符合 Java EE 的 Spring 项目,我们在 Tomcat 中遇到了这个问题。要解决此问题,请执行命令列表以使项目符合 Java EE。
$ mvn eclipse:clean
- to clean the eclipse files like .project .classpath$ mvn eclipse:eclipse -Dwtpversion=2.0
to create the eclipse compatible with Java EE.
$ mvn eclipse:clean
- 清理 .project .classpath 之类的 eclipse 文件$ mvn eclipse:eclipse -Dwtpversion=2.0
创建与 Java EE 兼容的 Eclipse。
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.
最后在eclipse中打开项目选择服务器tomcat现在点击在服务器上运行(Alt+Shift+x,R)选择tomcat7.0运行。
回答by Piyush Vashisht
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!
转到 Project Properties -> Project Facets 并更改动态 Web 模块的版本。如果设置为 3.1,则将其更改为 3.0。如果它不允许您更改版本,请取消选中它并按应用。然后您可以选择版本,检查它并应用-确定。为我工作!
回答by Ankit Pandey
For Tomcat Version 6
对于 Tomcat 版本 6
In project, .settingsfolder OR Or CTRL+SHIFT+R : find this file
在项目中,.settings文件夹 OR 或 CTRL+SHIFT+R :找到这个文件
org.eclipse.wst.common.project.facet.core.xml
org.eclipse.wst.common.project.facet.core.xml
change the version of facet=jst.webto 2.4 or 2.5
将facet=jst.web的版本更改为 2.4 或 2.5
File : org.eclipse.wst.common.project.facet.core.xml
文件: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 7You need facet="jst.web" version="3.0" to deploy on Tomcat 7.
Tomcat 7您需要 facet="jst.web" version="3.0" 才能在 Tomcat 7 上部署。
回答by Harsha Thota
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,
如果您在尝试将项目添加到 Tomcat 7 时遇到“Tomcat 7.0 版仅支持 J2EE 1.2、1.3、1.4 和 Java EE 5 和 6 Web 模块”错误。简单地说,
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.
右键单击项目--> 转到project facets--> 取消选中dymanic web 模块(应该是3.1)--> 应用--> 然后将动态web 模块更改为3.0--> 应用然后保存。
Try to add now and it should work.
现在尝试添加,它应该可以工作。
回答by ggwp
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
1)转到eclipse工作区中文件夹上的项目。
2)打开.setting文件夹
3)打开“org.eclipse.wst.common.project.facet.core”xml文件
4)将最后一行的版本更新为2.4或2.5
5)刷新项目并尝试运行服务器
回答by thonnor
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
Tomcat 7.0 版仅支持 J2EE 1.2、1.3、1.4 和 Java EE 5 和 6 Web 模块
which then also led to
这也导致
Cannot change version of project facet Dynamic Web Module to version 3.0
无法将项目构面动态 Web 模块的版本更改为 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)
在我们的项目中,我们使用 Maven 构建 Java 1.8 / Tomcat 8.5 应用程序(仅支持动态 Web 模块版本 3.0 - 不支持 4.0)
Someone in our team made the following change in our parent pom.xml
我们团队中的某个人在我们的父 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.1to 4.0.0and 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.
该版本已从3.0.1移至4.0.0并且无论我尝试org.eclipse.wst.common.project.facet.core.xml
用正确的版本手动覆盖多少次,<installed facet="jst.web" version="3.0"/>
Maven 更新都会用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 :)
我将版本设置回 3.0.1,如下所示,从那时起我的 Project Facets 显示了正确的版本,我的应用程序正在部署到我的内部 Tomcat 服务器,直到今天,没有人愿意更新版本 4.0.0 :)
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
回答by mannedear
This problem can be resolved by by changing the Dynamic Web Module version to 3.0. This can be done in 2 ways.
可以通过将动态 Web 模块版本更改为 3.0 来解决此问题。这可以通过两种方式完成。
Goto project properties and click on project facets, now you see the option
Dynamic Web Module
, change it to 3.0For 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"/>
转到项目属性并单击项目方面,现在您看到选项
Dynamic Web Module
,将其更改为 3.0对于上面步骤中无法更改版本的人,请打开
org.eclipse.wst.common.project.facet.core.xml
并将此处的版本更改为类似<installed facet="jst.web" version="3.0"/>
Now go to project facets and see the Dynamic Web Module
version changed to 3.0
现在转到项目方面并查看Dynamic Web Module
版本更改为3.0
回答by darvycode
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
.
要解决此问题,您必须Dynamic Web Module
从3.1 to 3.0
. Eclipse 不允许直接通过Build Path-->Configure Build Path-->Project Facets
.
Follow these steps
Open file : YourPrjectFolder/.setting/org.eclipse.wst.common.project.facet.core
按照以下步骤打开文件: YourPrjectFolder/.setting/org.eclipse.wst.common.project.facet.core
- In project folder, goto .settings folder.
- Open
org.eclipse.wst.common.project.facet.core
XML document. - Edit line
<installed facet="jst.web" version="3.1"/>
to<installed facet="jst.web" version="3.0"/>
- Save the changes.
- Goto Eclipse and refresh the project.
- 在项目文件夹中,转到 .settings 文件夹。
- 打开
org.eclipse.wst.common.project.facet.core
XML 文档。 - 将行编辑
<installed facet="jst.web" version="3.1"/>
为<installed facet="jst.web" version="3.0"/>
- 保存更改。
- 转到 Eclipse 并刷新项目。
You will be able to publish the your project now on Tomcat 7.
您现在可以在 Tomcat 7 上发布您的项目。
回答by vijaya bharathi
For Tomcat 8.5 if you are facing this issue, change your facet setting to 3.1
对于 Tomcat 8.5,如果您遇到此问题,请将您的构面设置更改为 3.1
Open file : {project_Folder}/.setting/org.eclipse.wst.common.project.facet.core
打开文件:{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.
打开 org.eclipse.wst.common.project.facet.core XML 文件。将版本改为3.1 保存并刷新项目,您会发现可以将资源添加到tomcat。
This worked for me.. Thanks
这对我有用..谢谢