Monday, July 4, 2016

Integrating Tomcat 8.5.x and TomEE 7.x in Eclipse

Are you also seeing below error when trying to integrate Tomcat 8.5.x or TomEE 7.x using Tomcat v8.0 Server plugin in Eclipse?

For searchbots, the error says The Apache Tomcat installation at this directory is version 8.5.3. A Tomcat 8.0 installation is expected. This error even occurs in the current Eclipse Neon release. Perhaps they'll fix it in Neon SR1 by adding a new Tomcat v8.5 Server plugin. But for now and for older versions a workaround is needed.

The Eclipse built-in Tomcat server plugin basically detects the server version based on server.info property of org/apache/catalina/util/ServerInfo.properties file of Tomcat's /lib/catalina.jar file which looks like below in case of Tomcat 8.5.3:

server.info=Apache Tomcat/8.5.3
server.number=8.5.3.0
server.built=Jun 9 2016 11:16:29 UTC

All we need to do is to edit the version in server.info property to start with 8.0. Any ZIP or JAR aware tool should do it to edit it on the fly. I'm myself using WinRAR for the job.

server.info=Apache Tomcat/8.0.8.5.3
server.number=8.5.3.0
server.built=Jun 9 2016 11:16:29 UTC

Finally, it works.

INFO: Starting Servlet Engine: Apache Tomcat/8.0.8.5.3

The same procedure applies to TomEE 7.x which is based on Tomcat 8.5.x.

The difference between Tomcat 8.0 and 8.5 is the integration of Jaspic which is the first step towards standardizing Java EE authentication as part of JSR375. You probably already know that the ways to configure Java EE container managed authentication are totally scattered across different servers, making third party libraries such as Shiro and Spring Security more attractive. Each server needed its own way of configuring "realms" or "identity stores" to manage the database of users, passwords and roles. This will with JSR375 be unified using annotations and CDI provided via standard javax.security.* API. See also a.o. the question Java EE authentication: how to capture login event?

1 comment:

Diptendu said...

With Neon comes "Tomcat 9" as a drop down option for Targeted Runtimes. However, there is a problem in picking up the "servlet-api.jar" from the Tomcat 9 "lib" folder (e.g., D:\apache-tomcat-9.0.0.M9\lib where D:\apache-tomcat-9.0.0.M9 was given as the Tomcat installation directory while creating the server) and so javax.servlet.* does leads to compile errors.

Selecting "servlet-api.jar" as an external jar or putting it in WEB-INF/lib works but is there a proper workaround?