Categories: misc

How to setup tomcat with Eclipse

This post shows how to setup tomcat with eclipse, in order to deploy applications from within eclipse [including Servlet 3.x projects]. This post is created with following environments, but should be well applicable for your environments:

  • Luna Service Release 2 (4.4.2)
  • Tomcat 8.0.24
  • JDK 1.7

Let’s get started.

In Eclipse, Open Window -> Show View -> Servers

Select a Server (Tomcat 8 in my case, yours might be different).

Click Next, select the folder where you unzipped the tomcat. Click Finish. You should see the server now.

Right click on Server -> properties

The Location mentioned is NOT correct and needs updating. Click on Switch Location. Apply then OK.

Again, Double click on Server, you should see following configuration.

Change it as shown below. For Server Path, refer to your local tomcat directory. For Deploy path refer to webapps folder inside that tomcat directory.

Save and close it. You should see your server gets started. Goto http://localhost:8080 [8080 is the default port but you may change it]. You should see welcome page.

Server is up. Now let’s deploy something and test that.

I will import one of my maven project into eclipse. Once imported, perform following:

  • right click on your project and choose properties.
  • click on Deployement Assembly.
  • click add
  • click on “Java Build Path Entries”
  • select “Maven Dependencies”
  • click Finish.

Now, Right click project – > Run As -> Run on server.

You newly configured tomcat should be available to be deployed on. Next.

You should see your project being added. Click on Finish.

You will be prompted for server restart, restart it. Deployment will be done, and you should see the home page of your app.

Voila. In case of any issue, don’t forget to contact me, together we will find the solution for your problem.

View Comments

  • Hi admin, after a while import source of you, i install Tomcat ver 8.0 is show this error. Can you help me fix this error? tks.

  • My Tomcat is located on a remote server. Following these steps, Eclipse did not leave me even create the server... Can you help me?

    • Hi Antonio,

      Indeed. Seems that Eclipse in-built support only allows local instances. But if you really have the need to deploy remotely, you may want to use Tomcat-maven-plugin instead. this & this Stackoverflow posts explains them very well.

  • hi
    while i m running this project i m getting 500 error exception: server.init() for servlet dispatcher there exception root cause org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appController': Injection of autowired dependencies failed
    kindly help me !!
    thanks in advance

Share
Published by

Recent Posts

Spring Boot + AngularJS + Spring Data + JPA CRUD App Example

In this post we will be developing a full-blown CRUD application using Spring Boot, AngularJS, Spring Data, JPA/Hibernate and MySQL,…

7 years ago

Spring Boot Rest API Example

Spring Boot complements Spring REST support by providing default dependencies/converters out of the box. Writing RESTful services in Spring Boot…

7 years ago

Spring Boot WAR deployment example

Being able to start the application as standalone jar is great, but sometimes it might not be possible to run…

7 years ago

Spring Boot Introduction + hello world example

Spring framework has taken the software development industry by storm. Dependency Injection, rock solid MVC framework, Transaction management, messaging support,…

7 years ago

Secure Spring REST API using OAuth2

Let's secure our Spring REST API using OAuth2 this time, a simple guide showing what is required to secure a…

8 years ago

AngularJS+Spring Security using Basic Authentication

This post shows how an AngularJS application can consume a REST API which is secured with Basic authentication using Spring…

8 years ago