Multiple contexts with the same path error running web service in Eclipse using Tomcat

白昼怎懂夜的黑 提交于 2019-11-27 16:58:44

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.

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.

danielad

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

<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.

Angie Echevarria

In Eclipse, go to the Servers project. Open the tree for the Tomcat version you are using. Open file server.xml and verify your Context tags.

In your eclipse IDE on project explorer acess the server.xml like in:

And remove context tags with duplicates references for your project:

Go to server.xml and Search for "Context" tag with a property name "docBase".

Remove the duplicate lines here. Then try to restart the server.

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.xml file 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.

in my case i have found duplicate Context tag :

<Context docBase="my-project" path="/my-project" reloadable="true" source="org.eclipse.jst.jee.server:my-project"/&gt;&lt;Context docBase="my-project" path="/smartphone-selfcare" reloadable="true" source="org.eclipse.jst.jee.server:my-project"/></Host>

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....

  1. In your project's Properties, choose "Web Project Settings".
  2. Change "Context root".
  3. Clean your server
  4. now you can restart your server

Eclipse >> project explorer >> servers >> server.xml >> tag >> remove duplicate tag of your project

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.

chethan bhounsley g

Try to delete the existing tomcat server in the server console. If you don't have the console then you can go to "Show view ->server", delete the server by right clicking on it, then add a new server.

If you are using Tomcat 7 and Eclipse, click on the Tomcat server and then goto the modules tab. There you will find the duplicate entry. Remove both the entry and redeploy the application. You are good to go now.

PenguinSource

On a related note, if you have copied a project or in anycase, have the same context path for 2 'active' projects, you have to change the context path of one of them, then clean the tomcat server settings, then republish the servers

see this in-more detailed answer

aPEARR

I had that problem before. I just solved it by expanding the tomcat tree and delete the folder that is causing the clash. in your case is /FirstApache. after you delete it. then you rerun it, you should be able to run. If it happens again, delete it and try again.

Remove the space or empty line in server.xml or context.xml at the beginning of your code

In my case I found duplicate paths in Servers/Tomcat5.5 at localhost-config/server.xml under tag. Removing the duplicates solved the problem.

Delete org.eclipse.wst.server.core and org.eclipse.wst.server.ui from .metadata/.plugins of wrokspace

delete the server from eclipse then reconfig the server in eclipse.

If you are using STS and your server is Pivotal Just double click on the server and go to >Modules tab >display Configure the Web Modules on this server.>you can just remove modules and run once again.

 //Trying to do more than one thing to the object in the same context, 
//the solution is to work on single context objects

public class SingletonContext<TContext>
    where TContext: DbContext,new()
{
    private static TContext _context;

    private SingletonContext()
    {

    }
    public static TContext GetInstance()
    {
        if (_context == null)
        {
            _context = new TContext();
        }
        return _context;
    }

}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!