eclipse Server Tomcat v9.0 Server at localhost 启动失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41875670/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 23:22:16  来源:igfitidea点击:

Server Tomcat v9.0 Server at localhost failed to start

javaeclipsetomcat

提问by Krishna

I am using Eclipse Neon and Tomcat server 9.0 and JDK 1.8 It was working well but unfortunately its giving me error 'Server Tomcat v9.0 Server at localhost failed to start.' I tried to change the ports i.e. connection port and other ports too but it did not solve my problem and this error is shown when I start the server or run the web app I am currently working on. Other solution other than change in port because I tried it and it did not resolve my problem?????

我正在使用 Eclipse Neon 和 Tomcat 服务器 9.0 和 JDK 1.8 它运行良好,但不幸的是它给了我错误“本地主机的服务器 Tomcat v9.0 服务器无法启动。” 我也尝试更改端口,即连接端口和其他端口,但它没有解决我的问题,并且当我启动服务器或运行我目前正在使用的 Web 应用程序时会显示此错误。除了更改端口之外的其他解决方案,因为我尝试过它并没有解决我的问题????

回答by amit kohan

I had the same problem with Tomcat 9.xx and Eclipse. None of the given solutions helped me.

我在 Tomcat 9.xx 和 Eclipse 上遇到了同样的问题。给定的解决方案都没有帮助我。

However, there is a missing step(for some of us) before recreating a new Server in Eclipseyou may need to add the path to a jar file. The missing step was browsing to your /Tomcat-Directory/lib/servlet-api and adding servlet-api.jar

但是,在 Eclipse 中重新创建新服务器之前缺少一个步骤(对于我们中的一些人),您可能需要将路径添加到 jar 文件。缺少的步骤是浏览到您的/Tomcat-Directory/lib/servlet-api 并添加 servlet-api.jar

Steps:

脚步:

1- Right click on the project you work on > Build Path > Configure Build Path > Libraries > Add External JARs

1-右键单击您正在处理的项目>构建路径>配置构建路径>库>添加外部JAR

2- Select all JAR files from the Tomcat/bin and Tomcat/lib

2- 从 Tomcat/bin 和 Tomcat/lib 中选择所有 JAR 文件

3- Click "OK"

3-点击“确定”

This made it work for me. I hope it will help you as well.

这使它对我有用。我希望它也能帮助你。

Thank you.

谢谢你。

回答by tamoghna saha

I uninstalled tomcat server, deleted the server from eclipse and reinstalled, reattached tomcat. It's running fine now.

我卸载了tomcat服务器,从eclipse中删除了服务器并重新安装,重新连接了tomcat。现在运行良好。

回答by Rafsun Jany Arman

If you can't detect which project creates the problem then simply add and remove it in your server and run. If defective project is not anymore added to the server then server will run correctly. After detecting the problem you can simply follow the steps below.

如果您无法检测到哪个项目产生了问题,那么只需在您的服务器中添加和删除它并运行即可。如果有缺陷的项目不再添加到服务器,则服务器将正常运行。检测到问题后,您只需按照以下步骤操作即可。

If you are using data base connection with connection pooling then make sure @Resource(name="jdbc/dbName")is written before private DataSource dataSourcein your servlet controller class. Just put it like this in your servlet controller class:

如果您使用带连接池的数据库连接,请确保在您的 servlet 控制器类中@Resource(name="jdbc/dbName")写入之前private DataSource dataSource。把它像这样放在你的 servlet 控制器类中:

@Resource(name="jdbc/sakila")
private DataSource dataSource;

回答by tarun kumar143

Right click on the project you work on > Build Path > Configure Build Path > Libraries > Add External JARs--servlet-api.jar and jsp-api.jar if you are deploying web Application

如果您正在部署 Web 应用程序,请右键单击您正在处理的项目 > 构建路径 > 配置构建路径 > 库 > 添加外部 JAR--servlet-api.jar 和 jsp-api.jar

回答by Aron Kim

There was once I had messed around the server.xmlfile, and unwittingly added a Context tag telling the server to load a project I wasn't looking to load, and therefore had not compiled. That threw the Server Tomcat v9.0 Server at localhost failed to start, which went away after I deleted that.

有一次我把server.xml文件弄乱了,不知不觉地添加了一个 Context 标签,告诉服务器加载一个我不想加载的项目,因此没有编译。这抛出了Server Tomcat v9.0 Server at localhost failed to start,在我删除它后它消失了。

回答by Gustavo Feliciano

Have you tried to put /in the webServlet above your class?

你有没有试过把/webServlet 放在你的班级上面?

@WebServlet("/nameURL")
public class MyClass extends HttpServlet{}

回答by lihinxgufin

  1. Go to directory (your workspace).metadata.plugins\org.eclipse.wst.server.core\tmp0\conf
  2. Open server.xml file on editor
  3. Delete <Context docBase="(your workspace)\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\(your old project)" path="/(your old project)" reloadable="true" source="org.eclipse.jst.jee.server:(your old project)"/>
  1. 转到目录(您的工作区)。metadata.plugins\org.eclipse.wst.server.core\tmp0\conf
  2. 在编辑器上打开 server.xml 文件
  3. 删除 <Context docBase="(your workspace)\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\(your old project)" path="/(your old project)" reloadable="true" source="org.eclipse.jst.jee.server:(your old project)"/>

there might be some left over from your old project. so, only delete projects that have not been used or that were previously deleted. because if you delete one line then your server will be able to run but not with your project. because some of your project lines were deleted too.

您的旧项目可能会遗留一些内容。因此,仅删除尚未使用或以前删除的项目。因为如果您删除一行,那么您的服务器将能够运行,但不能与您的项目一起运行。因为你的一些项目线也被删除了。