22.04 tomcat9 with openjdk8 JSP compilation error

Bug #1972829 reported by Nyari Zoltan
This bug affects 4 people
Affects Status Importance Assigned to Milestone
tomcat9 (Ubuntu)

Bug Description


After a new Ubuntu 22.04 install, we have installed the openjdk8 and tomcat9 packages:
sudo apt install openjdk-8-jdk
sudo apt install tomcat9

After the install we have tested it by deploying the sample application, from https://tomcat.apache.org/tomcat-9.0-doc/appdev/sample/

The Sample contains a simple JSP page, which throws an error:
Message java.lang.UnsupportedClassVersionError: org/eclipse/jdt/internal/compiler/env/INameEnvironment has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

This class is in the libeclipse-jdt-core-java package, which seems to be compiled using Java 11 target settings.

Tomcat 9 is officially supported on JDK 8, so I think the libeclipse-jdt-core-java package should also support Java 8.

Also we could find a workaround: installing the libecj-java package (which supports Java 8) and creating a symlink in the tomcat9 lib directory.


System Info:

Description: Ubuntu 22.04 LTS
Release: 22.04

  Installed: 9.0.58-1
  Candidate: 9.0.58-1
  Version table:
 *** 9.0.58-1 500
        500 http://hu.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
        100 /var/lib/dpkg/status

  Installed: 8u312-b07-0ubuntu1
  Candidate: 8u312-b07-0ubuntu1
  Version table:
 *** 8u312-b07-0ubuntu1 500
        500 http://hu.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
        100 /var/lib/dpkg/status

  Installed: 3.27.0+eclipse4.21-1
  Candidate: 3.27.0+eclipse4.21-1
  Version table:
 *** 3.27.0+eclipse4.21-1 500
        500 http://hu.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
        100 /var/lib/dpkg/status

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in tomcat9 (Ubuntu):
status: New → Confirmed
Revision history for this message
jmz (jmzb) wrote :

For references here is this same issue reported on the Debian bug tracker: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1006647

They seem to have decided to drop support for jre8 going forward, and thus have changed the tomcat9 package to depend on java11-runtime-headless rather than default-jre-headless (see this commit: https://salsa.debian.org/java-team/tomcat9/-/commit/f866eaf2e3db98fb785f012ceeb97ec04b141aa8)

@Nyari Zoltan, it would be a great help to me if you could be more specific about your workaround. What are the exact paths of the target and link in the symbolic link you created?

Thanks in advance,

Revision history for this message
Nyari Zoltan (nyariz) wrote :


Thanks, the workaround was (I hope I remember correctly):
sudo apt install libecj-java
sudo ln -s /usr/share/java/ecj.jar /var/lib/tomcat9/lib
sudo systemctl restart tomcat9

If I may suggest, I think Ubuntu (and also Debian) should support Tomcat9 running on OpenJDK 8, because it is still supported (as far as I know, the end-of-life dates have not been announced yet). There are a large number of internal/enterprise software which has not been ported to Java 11.

Best regards,

Revision history for this message
jmz (jmzb) wrote :

Hey Zoltan thank you very much for the instructions.

I also agree that Ubuntu should continue to support Tomcat9 on JDK8 for the same reason. With Debain it is less clear as they do not provided a JDK8 package in the official repositories any more, so I understand their reasoning.

As a side note, I would like to say that Debain Bullseye (stable) currently ships with libeclipse-jdt-core-java 4.18 (https://packages.debian.org/bullseye/libeclipse-jdt-core-java), which appears to be compiled for Java 8.

I have just successfully installed a Java 8 only tomcat9 web application on Debian Bullseye by installing JRE8 using the third party Adoptium repository to install temurin-8-jdk (see https://adoptium.net/installation/linux)

Obviously this does not solve the issue in regards to Ubuntu but I thought the information may be useful to some. It is unfortunate that this workaround will no longer be possible for the next major Debian release.

Revision history for this message
Lara Benson (lbenson2778) wrote :

I have this exact problem (Tomcat 9.0.58, Ubuntu 22.04, Java 8).

I tried Zoltan's workaround and installed libecj-java, but I still get the same 'INameEnvironment' 500 error when trying to load a page through Tomcat. I tried symlinking ecj.jar into both /var/lib/tomcat9/lib/ and /usr/share/tomcat9/lib/ (the latter is where my Tomcat 9 common library files installed; /var/lib/tomcat9/lib/ was empty out-of-the-box) (and of course I restarted Tomcat at each change). Neither attempt worked.

If I attempt to apt-remove the package libeclipse-jdt-core-java, APT insists on removing tomcat9 entirely, so I assume that's a no-go.

Does anyone have advice on how to get this workaround going? Am I missing something?


Revision history for this message
Lara Benson (lbenson2778) wrote :

Update: I've found another workaround of installing the older `libeclipse-jdt-core-java` JDT package from Ubuntu 20.04.

1. Add the line `deb http://de.archive.ubuntu.com/ubuntu/ focal main universe` to the end of `/etc/apt/sources.list`.

2. Update Apt (`$ sudo apt update`)

3. Install the old version of the package, specifying the older version:
$ sudo apt install libeclipse-jdt-core-java=3.18.0+eclipse4.12-1
Apt should identify this as a `DOWNGRADE` operation automatically, so there's no worry about conflicting package versions.

4. Hold this package back from further updates so that `apt upgrade` doesn't return it to the newer `3.27.0+eclipse4.21-1` version:
$ sudo apt-mark hold libeclipse-jdt-core-java

5. Delete the line `deb http://de.archive.ubuntu.com/ubuntu/ focal main universe` from `/etc/apt/sources.list` to restore its original state.

6. Upgrade Apt again (`$ sudo apt upgrade`)

7. Restart Tomcat (`$ sudo systemctl restart tomcat9.service`)

This worked for me on Ubuntu 22.04/Tomcat 9/Java 8.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.