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

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:

Could not publish server configuration for Tomcat v6.0 Server at localhost.
Multiple contexts have a path of "/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.

How can I fix this?

This question is related to eclipse web-services tomcat axis

The answer is


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.


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.


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>

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


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.


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.


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.


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

enter image description here

And remove context tags with duplicates references for your project:

enter image description here


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


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.


This error occurs when you copy a project than past it, and then you change the name of that project.

in such a case, follow the following steps.

Step-1: you need to edit your web.xml file. remove servlet and servlet-mapping of the previous projects.

Step-2: got to SERVER--> server.xml--> find context

Example :- Context docBase="JSPandServletDemo" path="/JSPandServletDemo" reloadable="true" source="org.eclipse.jst.jee.server:JSPandServletDemo"/>

now you just need to change the pathname to your current project name.

Good Luck Happy Coding :)


 //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;
    }

}

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.


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.


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.


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

enter image description here


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.


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


  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

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


Examples related to eclipse

How do I get the command-line for an Eclipse run configuration? My eclipse won't open, i download the bundle pack it keeps saying error log strange error in my Animation Drawable How to uninstall Eclipse? How to resolve Unable to load authentication plugin 'caching_sha2_password' issue Class has been compiled by a more recent version of the Java Environment Eclipse No tests found using JUnit 5 caused by NoClassDefFoundError for LauncherFactory How to downgrade Java from 9 to 8 on a MACOS. Eclipse is not running with Java 9 "The POM for ... is missing, no dependency information available" even though it exists in Maven Repository The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. on deploying to tomcat

Examples related to web-services

How do I POST XML data to a webservice with Postman? How to send json data in POST request using C# org.springframework.web.client.HttpClientErrorException: 400 Bad Request How to call a REST web service API from JavaScript? The request was rejected because no multipart boundary was found in springboot Generating Request/Response XML from a WSDL How to send a POST request using volley with string body? How to send post request to the below post method using postman rest client How to pass a JSON array as a parameter in URL Postman Chrome: What is the difference between form-data, x-www-form-urlencoded and raw

Examples related to tomcat

Jersey stopped working with InjectionManagerFactory not found The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. on deploying to tomcat Spring boot: Unable to start embedded Tomcat servlet container Tomcat 404 error: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists Spring Boot application in eclipse, the Tomcat connector configured to listen on port XXXX failed to start Kill tomcat service running on any port, Windows Tomcat 8 is not able to handle get request with '|' in query parameters? 8080 port already taken issue when trying to redeploy project from Spring Tool Suite IDE 403 Access Denied on Tomcat 8 Manager App without prompting for user/password Difference between Xms and Xmx and XX:MaxPermSize

Examples related to axis

R barplot Y-axis scale too short How can I change the font size of ticks of axes object in matplotlib Multiple contexts with the same path error running web service in Eclipse using Tomcat Please initialize the log4j system properly. While running web service Secondary axis with twinx(): how to add to legend? Content is not allowed in Prolog SAXParserException Python, Matplotlib, subplot: How to set the axis range? rotating axis labels in R Difference between Apache CXF and Axis How to add custom Http Header for C# Web Service Client consuming Axis 1.4 Web service