简体   繁体   English

Tomcat v7.0停止在本地主机上运行我的项目

[英]Tomcat v7.0 stopped to run my project at localhost

I was working on my web application in eclipse with Tomcat v7.0, and everything was fine. 我正在使用Tomcat v7.0在Eclipse中处理Web应用程序,一切都很好。
But today suddenly I can't run my poject on server anymore. 但是今天突然我不能在服务器上运行我的项目了。
I do as usual: 我照常做:
Right click on my project->Run As->Run on Server and then choose to run it on my Tomcat server, but I get this error: 右键单击我的项目->运行方式->在服务器上运行,然后选择在Tomcat服务器上运行它,但出现此错误:

'Publishing to Tomcat v7.0 Server at localhost...'  
has encountered a problem  

Removing obsolete files from server...
Could not clean server of obsolete files: Premature end of file.
Premature end of file.

Does anyone know what should I do please? 有人知道我该怎么办吗?

web.xml : web.xml

<?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_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>LinkedIn</display-name>
  <welcome-file-list>
    <welcome-file>login.jsp</welcome-file>
  </welcome-file-list>
</web-app>

I had similar problem, but java.lang.NullPointerException instead. 我有类似的问题,但是java.lang.NullPointerException代替了。

For me the only thing that worked was to: 对我而言,唯一起作用的是:

  1. Right-click on server instance on servers view -> Properties -> Switch Location ; 右键单击服务器视图上的服务器实例->属性->交换机位置
  2. Remove all published projects from server; 从服务器中删除所有已发布的项目;
  3. Right click on server again and do both cleans. 再次右键单击服务器,然后进行两次清理。

Hope that helps! 希望有帮助!

双击服务器查找服务器路径, 删除 C:\\src\\trunk\\.metadata\\.plugins\\org.eclipse.wst.server.core名为tmp0的文件夹

I solved this by deleting the working directory of my Tomcat server, cleaning , and republishing . 我通过删除 Tomcat服务器的工作目录, 清理重新发布解决了此问题。 For reference, my working directory was: 作为参考,我的工作目录为:

{eclipse-workspace}/.metadata/.plugins/org.eclipse.wst.server.core

And my server was tmp0 . 我的服务器是tmp0 I've seen other people have servers under different directories. 我见过其他人在不同目录下有服务器。 I found this path after double clicking on the Tomcat server in eclipse. 在Eclipse中双击Tomcat服务器后,我找到了此路径。 That brings up a configuration menu and it lists the "Server Location". 这将显示一个配置菜单,并列出“服务器位置”。

Download and install the zip file of tomcat instead of 32 bit windows zip and 64 bit windows zip. 下载并安装tomcat的zip文件,而不是32位Windows zip和64位Windows zip。 Add it to server- Window->Pref->Server->Runtime Env 将其添加到服务器-窗口-> Pref->服务器->运行时环境

Download link 下载链接

Apache Tomcat download page https://tomcat.apache.org/download-70.cgi Apache Tomcat下载页面https://tomcat.apache.org/download-70.cgi

Recheck your web.XML file. 重新检查您的web.XML文件。

This error just because of web.xml configuration or sometime need to clean & build whole project from 该错误仅是由于web.xml配置所致,或者有时需要从中清理并构建整个项目

Project>clean

Server clean 服务器干净

Server>right click>delete

Then 然后

Setup new server

Also you can remove these files: 您也可以删除以下文件:

org.eclipse.wst.server.core.prefs
org.eclipse.jst.server.tomcat.core.prefs

from $your_path/workspaceEclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings 来自$your_path/workspaceEclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings

and make new server again. 再次制作新服务器。

In my case it was due to a BSOD during the deploy procedure. 就我而言,这是由于在部署过程中出现了BSOD。 I had a couple of corrupted files (in Tomcat config) in the destination tomcat, so eclipse could not parse them to check if a redeploy was needed. 我在目标tomcat中有几个损坏的文件(在Tomcat配置中),因此eclipse无法解析它们以检查是否需要重新部署。

In my case, when I had same issue I understood that I previously commented out the Host node with name="localhost" in server.xml. 就我而言,当我遇到相同的问题时,我了解到我之前已经在server.xml中注释掉了名称为“ localhost”的Host节点。

Example: 例:

<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true"></Host>

And since then I was getting this Exception each time I tried to publish changes to Tomcat. 从那时起,每次我尝试将更改发布到Tomcat时,我都会收到此Exception。

But the problem is, when I opened server.xml in eclipse and I removed comment brackets from this Host, saved changes and tried o publish again, I was still getting this Exception. 但是问题是,当我在eclipse中打开server.xml并从该主机中删除注释括号,保存更改并尝试再次发布时,我仍然遇到此异常。 Restarting Eclipse, deleting tmp0 folder in C:\\src\\trunk.metadata.plugins\\org.eclipse.wst.server.core did not help. 重新启动Eclipse,删除C:\\ src \\ trunk.metadata.plugins \\ org.eclipse.wst.server.core中的tmp0文件夹无济于事。

What helped is openning server.xml in other than Eclipse editor. 帮助之外的是 Eclipse编辑器之外打开server.xml It is appeared that this Host stayed commented out in it, so Eclipse did not actually apply changes unless publishing is successfull. 似乎该主机未在其中添加注释,因此,除非发布成功,否则Eclipse实际上不会应用更改。 So I removed comment brackets from this Host in other text editor, saved changes, returned to Eclipse and publishing worked again! 因此,我在其他文本编辑器中从此Host删除了注释括号,保存了更改,返回到Eclipse并再次发布!

Hope it will help to somebody. 希望对别人有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM