eclipse “本地主机上的服务器 Tomcat v7.0 服务器无法启动”在终端中工作时没有堆栈跟踪
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13244233/
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
"Server Tomcat v7.0 Server at localhost failed to start" without stack trace while it works in terminal
提问by Marvin Effing
So got this project which worked just fine before the weekend (have other problems, but at least Tomcat launched). Now when I try to launch the Tomcat server it immediately gives the following error:
所以这个项目在周末之前运行得很好(有其他问题,但至少 Tomcat 启动了)。现在,当我尝试启动 Tomcat 服务器时,它立即出现以下错误:
Server Tomcat v7.0 Server at localhost failed to start.
However, I can start Tomcat just fine via Terminal, and this problem is occurring in Eclipse (Eclipse Java EE IDE for Web Developers. Version: Juno Service Release 1 Build id: 20121004-1855)
但是,我可以通过终端很好地启动 Tomcat,并且这个问题发生在 Eclipse 中(Eclipse Java EE IDE for Web Developers。版本:Juno Service Release 1 Build id:20121004-1855)
I scoured several forums trying to find a solution but to no avail! Please help someone out in need.
我搜索了几个论坛试图找到解决方案,但无济于事!请帮助有需要的人。
采纳答案by Ami
To resolve this issue, you have to delete the .snap
file located in the directory:
要解决此问题,您必须删除.snap
位于目录中的文件:
<workspace-directory>\.metadata\.plugins\org.eclipse.core.resources
After deleting this file, you could start Eclipse with no problem.
删除此文件后,您可以毫无问题地启动 Eclipse。
回答by chandrsekar.L.S.
Open the Servers Tab from Windows → Show View → Servers menu
Right click on the server and delete it
Create a new server by going New → Server on Server Tab
Click on "Configure runtime environments…" link
Select the Apache Tomcat v7.0 server and remove it. This will remove the Tomcat server configuration. This is where many people do mistake – they remove the server but do not remove the Runtime environment.
Click on OK and exit the screen above now.
From the screen below, choose Apache Tomcat v7.0 server and click on next button.
Browse to Tomcat Installation Directory
Click on Next and choose which project you would like to deploy:
Click on Finish after Adding your project
Now launch your server. This will fix your Server timeout or any issues with old server configuration. This solution can also be used to fix “port update not being taking place” issues.
从 Windows → 显示视图 → 服务器菜单打开服务器选项卡
右键单击服务器并删除它
通过转到“服务器”选项卡上的“新建”→“服务器”来创建新服务器
单击“配置运行时环境...”链接
选择 Apache Tomcat v7.0 服务器并将其删除。这将删除 Tomcat 服务器配置。这就是很多人犯错的地方——他们删除了服务器,但没有删除运行时环境。
单击“确定”并立即退出上面的屏幕。
从下面的屏幕中,选择 Apache Tomcat v7.0 服务器并单击下一步按钮。
浏览到 Tomcat 安装目录
单击 Next 并选择您要部署的项目:
添加项目后点击完成
现在启动您的服务器。这将修复您的服务器超时或旧服务器配置的任何问题。此解决方案还可用于修复“未进行端口更新”的问题。
回答by jaideep
To resolve this issue you have to delete tmp folderin the following directory
要解决此问题,您必须删除以下目录中的tmp 文件夹
<workspace-directory>\.metadata\.plugins\org.eclipse.wst.server.core
If there is any problem on deleting this folder then restart your eclipse then again delete that folder.
如果删除此文件夹有任何问题,请重新启动 eclipse,然后再次删除该文件夹。
回答by CodyBugstein
In my case, the problem was in the xml
code somehow.
就我而言,问题出在xml
代码中。
My web.xml
file looked like this:
我的web.xml
文件是这样的:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>index</servlet-name>
<jsp-file>index.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>index</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
but I changed it to look like
但我把它改成这样
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
and now the server loads up properly. Strange.
现在服务器正常加载。奇怪的。
回答by C0de8ug
i encountered this problem ,becaues i define servlet mapping in servlet class and web.xml.
我遇到了这个问题,因为我在 servlet 类和 web.xml 中定义了 servlet 映射。
You must to be careful to check whether you have defined servlet mapping in your servlet class and web.xml
你必须小心检查你是否在你的 servlet 类和 web.xml 中定义了 servlet 映射
1)delete @WebServlet("...")
1)删除 @WebServlet("...")
@WebServlet("/Login")
public class Login extends HttpServlet {
}
OR
或者
2)delete <servlet></servlet> <servlet-mapping></servlet-mapping>
2)删除 <servlet></servlet> <servlet-mapping></servlet-mapping>
<servlet>
<servlet-name>ServletLogin</servlet-name>
<servlet-class>Login</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletLogin</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
Reason:
原因:
I use apache tomcat 7.0 which supports servlet 3.0.
我使用支持 servlet 3.0 的 apache tomcat 7.0。
With Java EE annotations, the standard web.xml deployment descriptor is
使用 Java EE 注释,标准的 web.xml 部署描述符是
optional. According to the servlet 3.0 specification at
可选的。根据 servlet 3.0 规范
回答by C0de8ug
Server Tomcat v7.0 Server at localhost failed to start.
服务器 Tomcat v7.0 服务器在 localhost 启动失败。
This error resolve following three case
此错误解决以下三种情况
1.Clean project & server
1.清理项目和服务器
Or
或者
2.Remove .snap file from this directory
2.从此目录中删除.snap文件
<workspace-directory>\.metadata\.plugins\org.eclipse.core.resources
Or
或者
3.Remove temp file from this directory
3.从此目录中删除临时文件
<workspace-directory>\.metadata\.plugins\org.eclipse.wst.server.core
回答by John
None of the answers mentioned above worked for me. I am using Tomcat 9 in my Eclipse IDE. Hence I tried the following steps on my Eclipse Neon.
上面提到的答案都不适合我。我在 Eclipse IDE 中使用 Tomcat 9。因此,我在 Eclipse Neon 上尝试了以下步骤。
Step #1:Click on Servers
tab to see your server. In my case, it looks like the following:
第 1 步:单击Servers
选项卡以查看您的服务器。就我而言,它看起来如下所示:
Step #2:Right click on the server, select Properties
, you will see the following window. Click on Switch Location
, it will change the location to the one shown in the image below from the default one.Click on Apply
and then OK
to close the window.
步骤#2:右键单击服务器,选择Properties
,您将看到以下窗口。单击Switch Location
,它将从默认位置更改为下图所示的位置。单击,Apply
然后OK
关闭窗口。
Step #3Double click on the Tomcat Server which will open the Overview
option as shown in the image below. The Server Locations
part was active for me when I did (it's shown inactive in the image because I already did that at my end and I have my server running) that and I selected the second radio button option which is Use Tomcat installation (takes control of Tomcat installation)
. I then closed this option , saved the changes when prompted and started my server. It started working fine.
步骤 #3双击 Tomcat 服务器,这将打开Overview
如下图所示的选项。Server Locations
当我这样做时,该部分对我来说是活动的(它在图像中显示为非活动状态,因为我已经在最后这样做了并且我的服务器正在运行)并且我选择了第二个单选按钮选项,即Use Tomcat installation (takes control of Tomcat installation)
. 然后我关闭了这个选项,在提示时保存了更改并启动了我的服务器。它开始工作正常。
回答by Emad Abdelhamid
In my case, the problem was in the web.xml file, where i forgot to precede the url-pattern with a "/" (e.g. /login.do).
就我而言,问题出在 web.xml 文件中,我忘记在 url-pattern 前面加上“/”(例如 /login.do)。
What solved my problem was, as mentioned above by @Ajak6, by adding the servlet API as an external JAR library for the project.
正如@Ajak6 上面提到的,解决我的问题的方法是将 servlet API 添加为项目的外部 JAR 库。
However, I found a better way, by adding Tomcat to the target runtime as follow;
但是,我找到了一个更好的方法,将 Tomcat 添加到目标运行时,如下所示;
1) project > properties
1)项目>属性
2) on the side menu select "Targeted runtimes"
2)在侧面菜单上选择“目标运行时”
3) select Tomcat (click apply)
3)选择Tomcat(点击应用)
4) click ok
4)点击确定
回答by djangodude
open your web.xml file. (if you don't know where is it, then just google it.) it is like this:
打开您的 web.xml 文件。(如果你不知道它在哪里,那就谷歌一下。)它是这样的:
<?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_3_1.xsd" id="WebApp_ID" version="3.1">
.
.
.
.
</web-app>
just below the <?xml version="1.0" encoding="UTF-8"?>
line, add a tag <element>
and close it in the very bottom with </element>
tag. Done.
就在该<?xml version="1.0" encoding="UTF-8"?>
行下方,添加一个标签<element>
并在最底部用</element>
标签将其关闭。完毕。
回答by Vibhor Bhardwaj
Creating a new workspace can also resolve this issue..
创建一个新的工作区也可以解决这个问题..