How to use Tomcat 8.5.x and TomEE 7.x with Eclipse?
Asked Answered
E

11

98

I need to setup a Tomcat 8.5.x server version in Eclipse. When I try to create a server using Eclipse GUI, I get in Eclipse Luna as choice the latest version "Apache Tomcat v8.0". When I select it and I browse to my Tomcat 8.5.x server, I get this blocking error message:

The Apache Tomcat installation at this directory is version 8.5.0. A Tomcat 8.0 installation is expected.

The same error appears when trying TomEE 7.x, which is internally based on Tomcat 8.5.

In Eclipse Neon the latest version as choice is "Apache Tomcat v9.0" and it gives the same error. There isn't even a "Apache Tomcat v8.5" option.

Is there a way to use Tomcat 8.5 and TomEE 7.x in Eclipse? How?

Eugenol answered 4/5, 2016 at 10:19 Comment(0)
G
136

You have to patch catalina.jar, as this is version number the WTP adapter looks at. It's a quite useless check, and the adapter should allow you to start the server anyway, but nobody has though of that yet.

For years and with every version of Tomcat this is always a problem.

To patch you can do the following:

  • cd [tomcat or tomee home]/lib
  • mkdir catalina
  • cd catalina/
  • unzip ../catalina.jar
  • vim org/apache/catalina/util/ServerInfo.properties

Make sure it looks like the following (the version numbers all need to start with 8.0):

server.info=Apache Tomcat/8.0.0
server.number=8.0.0
server.built=May 11 2016 21:49:07 UTC

Then:

  • jar uf ../catalina.jar org/apache/catalina/util/ServerInfo.properties
  • cd ..
  • rm -rf catalina
Gelasias answered 3/6, 2016 at 12:27 Comment(9)
In Tomcat 8.5.3, catalina.jar is in the lib folder.Minervamines
+1. For those using Windows OS, you can make the required changes right in the JAR file. Just open the catalina.jar with your file archive utility (WinRar, WinZip, 7zip etc), navigate to the org\apache\catalina\util\ServerInfo.properties file, make changes and save them (confirm that you want to update the archive).Vouge
UPDATE And you ONLY need to change the version in the server.info= line (like server.info=Apache Tomcat/8.0.0), and server.number can be left as it is. For instance I have left it untouched like this: server.number=8.5.4.0. Works without a problem.Vouge
Note that in order to do the updates to the ServerInfo.properties file, Tomcat must be stopped or else you may hit some locking issues (i.e. The file is in use by another program) .Swanson
-1: modifying the server to claim to be a different version is a bit of hack, when clearly the appropriate thing to do is to modify eclipse to accept the actual version which has been done and is described in other answers.Tiberius
@PeriataBreatta It's a hack for sure. Perhaps you should link to those other answers ;)Gelasias
After applying this hack, I got "Unknown version of Tomcat was specified." errorHarlequinade
@AtmeshMishra Check the file permissions of catalina.jar.Guttering
@AtmeshMishra I got the same error, and startup.bat refused to run, even when I changed catalina.jar back to the way it was orginally. Ended up having to reinstall tomcatScrounge
T
44

There is a patch for Eclipse:
https://bugs.eclipse.org/bugs/attachment.cgi?id=262418&action=edit

Download this patch and put it to the plugins directory of your Eclipse installation. It will replace the default "org.eclipse.jst.server.tomcat.core_1.1.800.v201602282129.jar".

NOTE
After you add this patch you must choose "Apache Tomcat v9.0" when adding a server runtime environment in the Eclipse (Preferences > Server > Runtime Environments).
I.e. this patch allows you to select either Tomcat version 9.x or Tomcat version 8.5.x when adding Apache Tomcat v.9.0 runtime environment.


More details on can be found on the related bug report page: https://bugs.eclipse.org/bugs/show_bug.cgi?id=494936

Towery answered 29/6, 2016 at 12:20 Comment(3)
Note that this update now appears to be included in recent distributions of Neon, so simply choosing the Tomcat 9.x option might work without needing to update the plugin.Tiberius
Did not work for Version: Luna Service Release 2 (4.4.2) my tomcat adapters are missing after the patchRattlebrained
I'm using the eclipse version Mars.2 (4.5.2) and applied this patch. Now the existing tomcat adapters are all gone. This is crazy patch, I'm rolling it back now.Astrobiology
E
37

For Tomcat 8.5.x users

You've to change the ServerInfo.properties file of Tomcat's /lib/catalina.jar file.

ServerInfo.properties file contains the following code

server.info=Apache Tomcat/8.5.4
server.number=8.5.4.0
server.built=Jul 6 2016 08:43:30 UTC

Just open the ServerInfo.properties file by opening the catalina.jar with winrar from your Tomcat's lib folder

ServerInfo.properties file location in catalina.jar is /org/apache/catalina/util/ServerInfo.properties

Notice : shutdown the Tomcat server(if it's already opened by cmd) before doing these things otherwise your file doesn't change and your winrar shows error.

Then change the following code in ServerInfo.properties

server.info=Apache Tomcat/8.0.8.5.4
server.number=8.5.4.0
server.built=Jul 6 2016 08:43:30 UTC

Restart your eclipse(if opened). Now it'll work...

ScreenShot of eclipse

Eke answered 1/8, 2016 at 6:59 Comment(2)
Does it work on OS X too? I've just patched my catalina.jar and it doesn't work (nothing has changed after the patch). My Eclipse version is: Eclipse Java EE IDE for Web Developers. Version: Mars.2 Release (4.5.2) Build id: 20160218-0600Democritus
Sure it'll work on OS X too.Initially, I did these changes on my Mac only. After that I planned to use Tomcat on windows. So I just did it and posted as answer here. Give it a try... @piotrdabEke
T
14

As for now Eclipse Neon service release is available. So if someone is still encounters this trouble, just go to

Help → Check for Updates

and install provided updates related to : org.eclipse.jst

Thisbee answered 8/10, 2016 at 15:50 Comment(6)
Note that you still need to select Apache Tomcat v9.0 from the list of server runtimes, which is a little counter-intuitive, but it does work.Tiberius
I have Eclipse Java EE IDE for Web Developers version Neon.1 Release (4.6.1). Among older Tomcat vestions I also have v8.0, v8.5 and v9.0 available in Define a New Server window. Maybe Eclipse version you use is different.Thisbee
I confirm that Eclipse Neon.1 (4.6.1) add a Tomcat v8.5 ServerSlay
Hmm.. I have 4.6.0 with WST upgraded via the suggested action and still don't have Tomcat 8.5 on the list... but Tomcat 9.0 does work. Bizarre.Tiberius
Eclipse Neon.3 (4.6.3) also has a Tomcat v8.5 ServerHemstitch
I had the same exact issue, running on ubuntu 18.04, Tomcat v8.5.50 and eclipse v4.11 . and this solution worked for me perfectly.Undulation
S
4

This workaround worked for me. I edited the serverInfo.properties file as given below:

server.info=Apache Tomcat/8.0.0
server.number=8.0.0.0
server.built=Oct 6 2016 20:15:31 UTC
Simulator answered 9/11, 2016 at 17:39 Comment(0)
A
3

I had similar issues with Eclipse Kepler v3.8 I had tomcat v8.5.37 installed. I couldn't see Apache v8.5 as an option. By skimming through StackOverflow I found Apache v9.0 is available on Eclipse Neon. Cool thing is you don't have to change your eclipse version. In your current Eclipse. Download WTP(Web Tools Package) by following the steps:

Step 1: Help >>> Install New Software. Copy this link in the Work with: http://download.eclipse.org/webtools/repository/neon

Step 2: Select JST Server Adapters and JST Server Adapters Extensions from the first package you see. Install those.

Step 3: Windows >>> Preferences >>> Server >>> Runtime Environments >>> Add..

You'll see Apache v9.0 there! It works!

Argil answered 11/4, 2019 at 12:40 Comment(1)
Thanks! I had just (re)installed Eclipse 2019-03 on my MacBook, and Tomcat is always the hardest plugin for me to find. I used download.eclipse.org/webtools/repository/2019-03Maximin
E
2

Install the latest version of eclipse(). It would have the option to add Tomcat 8.5.

Elata answered 29/11, 2017 at 9:53 Comment(0)
M
1

Go to the preview version of tomcat e.g. : tomcat 8.3 and copy catalina.jar file and paste into the existing tomcat which you have facing the issue

Mayolamayon answered 30/10, 2017 at 7:9 Comment(0)
U
0

Forgive me for invoking old problem. But it is like legendary, always happen for new users. The reason I am here is I want to purpose different answer. Rather simple. Please fo to windows->preference->Runtime Environment->search and select the folder where you download the server. It will automatically detect the server and you are good to go.

Uppercase answered 27/7, 2019 at 19:32 Comment(0)
J
0

I'm guessing that you are running Eclipse Mars, or an even earlier release. You need to upgrade to Eclipse Neon or later

Jemima answered 22/11, 2019 at 14:6 Comment(0)
N
0
Navigate to /apache-tomcat-8.5.65/lib/org/apache/catalina/util/ServerInfo.properties
Then change 
server.info=Apache Tomcat/8.5.65
server.number=8.5.4.0
server.built=Jul 6 2021 00:29:43 UTC




server.info=Apache Tomcat/8.0.8.5.4
server.number=8.5.4.0
server.built=Jul 6 2016 08:43:30 UTC
Nomadize answered 3/5, 2021 at 21:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.