使用 Tomcat 在 Eclipse 中运行 Web 服务时出现多个具有相同路径错误的上下文
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7239613/
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
Multiple contexts with the same path error running web service in Eclipse using Tomcat
提问by kkk
This is the error that I got when I created my first Axis2 web service using Eclipse. After I wrote the class, I created the web service with Apache Axis2. When I click the start server button in eclipse it gives an error message:
这是我使用 Eclipse 创建第一个 Axis2 Web 服务时遇到的错误。在我写完这个类之后,我用 Apache Axis2 创建了 Web 服务。当我在 Eclipse 中单击启动服务器按钮时,它会给出一条错误消息:
Could not publish server configuration for Tomcat v6.0 Server at localhost.
Multiple contexts have a path of "/FirstApache".
无法在本地主机上发布 Tomcat v6.0 服务器的服务器配置。
多个上下文的路径为“/FirstApache”。
FirstApache is the dynamic web project that I created before. I selected the correct web project from the configuration part in the web service wizard.
FirstApache 是我之前创建的动态 Web 项目。我从 Web 服务向导的配置部分中选择了正确的 Web 项目。
How can I fix this?
我怎样才能解决这个问题?
回答by Alex Ciminian
Search for the server.xml
file and check your <Context>
tags, probably there are multiple definitions for the same path. Remove the duplicates and it should work for you.
搜索server.xml
文件并检查您的<Context>
标签,可能同一路径有多个定义。删除重复项,它应该适合您。
Check out the answer here.
Auto-format the xml file (control+ shift+ f) since the second <Context>
tag may be on the same line, but outside the viewport and really far away from the visible one.
自动格式化 xml 文件 ( control+ shift+ f),因为第二个<Context>
标签可能在同一行上,但在视口之外并且离可见的标签很远。
回答by Daniel Adenew
In STS/Eclipse go to "project explorer" or "package explorer" and
there is a folder called "server." Open it and you will find server.xml
file. Inside this file at the bottom you find a definition like
在 STS/Eclipse 中,转到“项目资源管理器”或“包资源管理器”,有一个名为“服务器”的文件夹。打开它,你会发现server.xml
文件。在底部的这个文件中,你会发现一个定义,如
<Context docBase="myproject" path="/myproject" reloadable="true"
source="org.eclipse.jst.jee.server:myproject"/>
You might find duplicates of the same definition that you would need to remove.
您可能会发现需要删除的相同定义的重复项。
回答by Angie Echevarria
In Eclipse, go to the Serversproject. Open the tree for the Tomcat version you are using. Open file server.xmland verify your Context tags.
在 Eclipse 中,转到Servers项目。打开您正在使用的 Tomcat 版本的树。打开文件server.xml并验证您的上下文标签。
回答by Fernando Gomes
回答by Sireesh Yarlagadda
Go to server.xml
and Search for "Context"
tag with a property name "docBase"
.
转到server.xml
并搜索"Context"
带有属性名称的标签"docBase"
。
Remove the duplicate lines here. Then try to restart the server.
删除这里的重复行。然后尝试重新启动服务器。
回答by sofiene zaghdoudi
Go to the Servers project in eclipse, under your runtime server configuration(in my case Tomcat v7.0 Server at localhost-config) go to server.xmlfile then search for <context> tag, normally you will find more than one context tag, delete them and run your application in the appropriate server that will work now.
转到 eclipse 中的 Servers 项目,在你的运行时服务器配置下(在我的例子中是 Tomcat v7.0 Server at localhost-config)转到server.xml文件然后搜索 <context> 标签,通常你会找到多个上下文标签,删除它们并在现在可以工作的适当服务器中运行您的应用程序。
in my case i have found duplicate Context tag :
就我而言,我发现了重复的 Context 标签:
<Context docBase="my-project" path="/my-project" reloadable="true" source="org.eclipse.jst.jee.server:my-project"/><Context docBase="my-project" path="/smartphone-selfcare" reloadable="true" source="org.eclipse.jst.jee.server:my-project"/></Host>
回答by Zeeshan Akhter
In eclipse using tomcat you just open this server.xml file and find Context tag and here you see your context name is more then one you just delete useless contexts and restart your server it will working....
在使用 tomcat 的 Eclipse 中,您只需打开此 server.xml 文件并找到 Context 标记,在这里您会看到您的上下文名称不止一个,您只需删除无用的上下文并重新启动服务器,它就会工作....
回答by debika sadhukhan
Eclipse >> project explorer >> servers >> server.xml >> tag >> remove duplicate tag of your project
Eclipse >> 项目资源管理器 >> 服务器 >> server.xml >> 标签 >> 删除项目的重复标签
回答by Fakher
- In your project's Properties, choose "Web Project Settings".
- Change "Context root".
- Clean your server
- now you can restart your server
- 在项目的属性中,选择“Web 项目设置”。
- 更改“上下文根”。
- 清理你的服务器
- 现在您可以重新启动服务器
回答by Phoenix
Simply remove the server in Eclipse and add tomcat server again. than shutdown the tomcat in tomcat/bin/shutdown.bat file and start the server in eclipse.
只需在 Eclipse 中删除服务器并再次添加 tomcat 服务器。比在 tomcat/bin/shutdown.bat 文件中关闭 tomcat 并在 eclipse 中启动服务器。