Setup Tomcat7 as Server in Eclipse Luna under Ubuntu Linux 1

On your Ubuntu (12.04/14.04/14.10/15.04) , if you have installed tomcat7 from the repositories then adding them as a server in Eclipse would need some tweaks.

Getting the tomcat to be administrered from Eclipse makes it easy if you are developing enterprise applications on Java using Tomcat7 as your app server.

I have used Eclipse for Java EE version 4.4.2 Luna for the example below.

Make sure you have tomcat7 installed correctly. Do ensure you have the tomcat7-admin package installed as well. Run the command below to check the same.

whereis tomcat7

you should get

/etc/tomcat7 /usr/share/tomcat7

Before you add a server in Eclipse ensure to run the following commands, the tomcat server in eclipse expects to have these files and folders in their respective locations for working correctly.

cd /usr/share/tomcat7
sudo ln -s /var/lib/tomcat7/conf conf
sudo ln -s /etc/tomcat7/policy.d/03catalina.policy conf/catalina.policy
sudo ln -s /var/log/tomcat7 log
sudo chmod -R 777 /usr/share/tomcat7/conf
sudo ln -s /var/lib/tomcat7/common common
sudo ln -s /var/lib/tomcat7/server server
sudo ln -s /var/lib/tomcat7/shared shared

If you are going to solely use Eclipse to start and stop tomcat server then remove the tomcat7 from the startup script to disable it from starting automatically everytime the machine boots up.

sudo service tomcat7 stop
sudo update-rc.d tomcat7 disable

Now open the Java EE perspective in your Eclipse. Choose New server either from the File-> New menu or from New Server tab as shown below.

Screenshot from 2015-06-23 10:11:03

 

In the next screen choose Tomcat7 Server.

Screenshot from 2015-06-23 10:11:52

Enter the host name and server name as shown above. You will find the Server runtime environment to be empty. Click Add.. next to it to configure the tomcat7 server as shown below.

Screenshot from 2015-06-23 10:11:52-2

 

Use /usr/share/tomcat7 as the tomcat installation directory or browse if you want to chose another custom installtion directory of tomcat7 and click finish.

Now on the server tab you should see the administrative options for tomcat7 as shown below.

Screenshot from 2015-06-23 10:22:46

 

The reason we did soft linking of folders earlier in the post is because the server setup here expects all the files and folders required for setup in one directory of /usr/share/tomcat7. You will find typical errors as shown below.

‘Could not load the Tomcat server configuration at /usr/share/tomcat7/conf. The configuration may be corrupt or incomplete /usr/share/tomcat7/conf/catalina.policy (No such file or directory)’

The above solution is taken from this answer by Joe on this question thread in stackexchange.

 

Please like & share:

One comment on “Setup Tomcat7 as Server in Eclipse Luna under Ubuntu Linux

  1. Reply Roland Bruggmann Sep 23,2015 7:35 pm

    Great documentation—thanks so much!

Leave a Reply

  

  

  


*