4

I'm trying to setup Tomcat in Eclipse. I've already followed this tutorial on how to install Tomcat and I'm even able to see the default Tomcat page at localhost:8080.

What I need now is to setup Tomcat on Eclipse.

I do the following:

Window->Preferences->Server->Runtime Environment->Add->"Apache Tomcat v8.5"

As Tomcat's installation directory I enter /opt/tomcat, as specified in the tutorial linked above in Step 3: Install Tomcat:

We will install Tomcat to the /opt/tomcat directory. Create the directory, then extract the archive to it [...]

But I get the following error:

Unknown version of Tomcat was specified.

As can be seen here:

enter image description here

Some more infos:

  • Tomcat 8.5.20
  • Eclipse Java EE IDE for Web Developers (4.7.0)
  • Ubuntu 17.04

Update:

When I check the permission with ls -ltra /opt/tomcat I get that output:

total 124
drwxr-x---  7 tomcat tomcat  4096 Aug  2 23:36 webapps
-rw-r-----  1 tomcat tomcat 15946 Aug  2 23:36 RUNNING.txt
-rw-r-----  1 tomcat tomcat  7064 Aug  2 23:36 RELEASE-NOTES
-rw-r-----  1 tomcat tomcat  1723 Aug  2 23:36 NOTICE
-rw-r-----  1 tomcat tomcat 57092 Aug  2 23:36 LICENSE
drwxr-xr-x  6 root   root    4096 Aug 11 17:56 ..
drwxr-x---  2 tomcat tomcat  4096 Aug 11 17:56 lib
drwxr-x---  2 tomcat tomcat  4096 Aug 11 17:56 bin
drwxr-x---  2 tomcat tomcat  4096 Aug 12 14:53 .oracle_jre_usage
drwxr-xr-x 10 tomcat tomcat  4096 Aug 12 14:53 .
drwxr-x---  3 tomcat tomcat  4096 Aug 12 14:53 work
drwxr-x---  3 tomcat tomcat  4096 Aug 12 15:01 conf
drwxr-x---  2 tomcat tomcat  4096 Aug 14 17:21 temp
drwxr-x---  2 tomcat tomcat  4096 Aug 14 17:21 logs
Evgenij Reznik
  • 17,916
  • 39
  • 104
  • 181
  • IntelliJ can deal with this. Maybe you need a smarter IDE. – duffymo Aug 14 '17 at 17:01
  • Are you sure the version of Tomcat that you have in that directory is, in fact, 8.5 ? – Alex Aug 14 '17 at 17:03
  • @AlexR: I think so. I installed it with: curl -O `http://apache.mirrors.ionfish.org/tomcat/tomcat-8/v8.5.20/bin/apache-tomcat-8.5.20.tar.gz` – Evgenij Reznik Aug 14 '17 at 17:06
  • Does that directory have `bin`, `conf`, etc directories? Or are they another level down? Also, maybe eclipse does not have the permissions to read that directory – tima Aug 14 '17 at 17:07
  • @tima: Yes, I can see the folders in that directory. How can I check the permission or how can I grant them to eclipse? – Evgenij Reznik Aug 14 '17 at 17:26
  • You can execute `ls -ltra /opt/tomcat` to see the permissions – tima Aug 14 '17 at 17:28
  • @tima: Please see my update. Can I grant eclipse default access to that folder? – Evgenij Reznik Aug 14 '17 at 18:13
  • I have a tomcat 8.5 running on a Mac, and my permissions are a bit different. `644` for files and `755` for directories. Yours are `640` and `750`. You can try to update them by using some commands inside the `/opt/tomcat/` folder. `find . -type f -exec chmod 644 {} +` and `find . -type d -exec chmod 755 {} +` – tima Aug 14 '17 at 18:28

3 Answers3

6

You just need to give permission

chmod -R 777 /opt/tomcat/
Jose N
  • 151
  • 2
  • 7
4

You really don't want Eclipse and a production installation of Tomcat to mix. The most straightforward thing to do is to download a tarball from http://tomcat.apache.org/ , unpack it, and point the Server->Runtime Environments preference page at that. This lets you sidestep any file permission issues as long as your make sure that they don't try to use the same ports.

nitind
  • 19,089
  • 4
  • 34
  • 43
  • Where can I find more information about that? Is the directory, where I unpack the zipped file, important? – Evgenij Reznik Aug 14 '17 at 18:46
  • More information on the differences between just using an installed copy or not, and some implications of distribution packages is in the Tomcat-specific FAQ at https://wiki.eclipse.org/WTP_Tomcat_FAQ . Where you unpack the download isn't that important, as long as you own that file tree. As for the preference page, I meant the **Server**->**Runtime Environments** preference page (answer updated to call it by name). – nitind Aug 14 '17 at 18:50
0

Open the Servers view and add the Tomcat server:

Window > Show View > Servers

In the Server view right click and select

New > Server

Now you'll get a window that looks like the one below. Open the Apache tab and scroll down to Tomcat 8.5 click on it and then click Next.

Add a new server in eclipse

In the next window you will be asked to select resources that are configured on the server. If you don't see any it means you will need to go to your project and add Dynamic Web Module facet. This can be done as follows:

Properties > Project Facets

Add facet to project

At this point you should be able to start the server and run your project using the controls in the top right of the Servers view, or by right clicking on the specific server. You can add several installations of Jetty, Tomcat, Resin, JBoss, etc if you need them by the way.

Momus
  • 394
  • 2
  • 13
  • After choosing "Apache Tomcat 8.5" and clicking next, I get to the window I posted where the error occurs. I don't get to the step where I can select the resources. – Evgenij Reznik Aug 14 '17 at 17:24
  • Oh, ok - this is a different problem than I thought. This problem crops up a fair bit with Eclipse unfortunately - I just dealt with it myself last week in fact. Take a look at these answers to see if they can help. https://stackoverflow.com/questions/17745834/unknown-version-of-tomcat-was-specified-with-tomcat-7-0-42 – Momus Aug 14 '17 at 17:40
  • If your problem doesn't have anything to do with the stuff outlined in the above link then try this one (which - ahem - is the link I actually meant to put in the comment above): https://stackoverflow.com/questions/31679099/eclipse-add-server-next-button-is-disabled-when-i-select-a-specific-tomcat – Momus Aug 14 '17 at 17:55
  • My Eclipse (for J2EE version) only lists up to Tomcat 7 ... but I have Tomcat 8.5 installed on my machine. How do I list up to 8.5? – Martyn Nov 07 '18 at 21:48