tech_truman
tech_truman

Reputation: 47

Changing default server for Eclipse project

Running a project on eclipse on Tomcat Server. I have two tomcat versions installed namely 7.0 and 9.0. I created two servers for the project. Stopped both servers. I want to run the project on 9.0. So I started server 9.0 But when I right click 'project-run as-run on server', it automatically starts 7.0 and because 9.0 is already using the port, 7.0 cannot start. Stopped 9.0. And run the project again now with both servers stopped. It automatically starts 7.0 but same error persists even with 9.0 stopped. (I have NOT set "always use this server for the project")

In targetted runtimes, configured the server I want to use for the project and applied the changes.

Run the project again, but the same error persists(BOTH servers in stop mode). How do I reconfig the servers?

Upvotes: 1

Views: 4298

Answers (1)

skomisa
skomisa

Reputation: 17363

There are a couple of points in your post that don't sound quite right:

I want to run the project on 9.0. So I started server 9.0...

Don't start the server. There is no need since when you select Run As > Run On Server the server will be started automatically.

But when I right click 'project-run as-run on server', it automatically starts 7.0

That will only happen if you have already set Tomcat 7.0 as the default server for your web application. The server for your app must be set to <None>. In Project Explorer select your project, right-click and select Properties, and then select Server. Verify that the selection for Always use the following server when running this project is set to <None>:

defaultServer

As long as your web application has no default server then you can do the following to switch between Tomcat 7 and Tomcat 9:

  1. Ensure all servers are stopped so your port is not being used.
  2. In Project Explorer select your app, right click and select Run As > Run On Server.
  3. The Run On Server dialog will be displayed, inviting you to select the server to be used. Select Tomcat 7.0 and click Finish.
  4. Tomcat 7.0 will start, and your app will be opened in the default browser.
  5. Stop Tomcat 7.0 from the Servers tab.
  6. Repeat steps 2 through 5 using Tomcat 9.0 instead of Tomcat 7.0.

I verified these instructions using Eclipse Oxygen.3a.

Upvotes: 3

Related Questions