You are not logged in.

#1 2024-07-15 06:01:36

Buwyi
Member
Registered: 2024-03-22
Posts: 1

tomcat8 compiled by a non-default version of java

When I was going to create a environment of

  • jdk1.8.x

  • tomcat8.x

At the very beginning, I don't know anything I just paru the tomcat8 package in the jdk17 like

 ❯ archlinux-java status
Available Java environments:
  java-17-openjdk(default)
  java-22-openjdk
 paru -S tomcat8 

Then, I found it was some problem of the webapp running on the tomcat8 and jdk17, I wanted to make it running on jdk8.  I paru the jre8-openjdk and use the archlinux-java to swith the jre,

❯ archlinux-java status
Available Java environments:
  java-17-openjdk
  java-22-openjdk
  java-8-openjdk (default)
❯ systemctl restart tomcat8.service

then the tomcat gave me

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 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

I tried a lot but earn nothing, here's the solution I had done

  • using tomcat with a different tomcat written in the wiki
    for this I edit in the drop-in-file and restart the service and got the same error

  • try to uninstall the package of tomcat8 and the eclipse-ecj and reinstall them on jdk8
    but i'm not sure if it is helpful, because i just easilly use

    pacman -Rs eclipse-ecj
    pacman -Rs tomcat8
    paru -S eclipse-ecj
    paru -S tomcat8

If there is a problem when the tomcat8 built-up from a package? Can I recompiled the tomcat8 package using jdk8?
Or if there is another way to deploy the .war file?
I would be more than thankful for your reply

<-------------SOLVED---------------->

I find a way to solve the proble. The easiest way is to download the tocmat and build it at the jdk8 environment. Here's the solution.
Make sure you are in the correct environment

archlinux-java 

Download the tomcat

wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.84/src/apache-tomcat-8.5.84-src.tar.gz
tar xzf apache-tomcat-8.5.84-src.tar.gz
mv apache-tomcat-8.5.84-src.tar.gz tomcat8
cd tomcat8

Apache gives a tool ant to help you build the code, so get the apache-ant and just type ant in the terminal at the directory.

sudo pacman -S apache-ant
ant

The files of tomcat are at the output/build, If you want to start or shutdown you can run the script.

sh output/build/bin/startup.sh
sh output/build/bin/shutdown.sh

Last edited by Buwyi (2024-07-18 02:17:17)

Offline

#2 2024-07-15 07:10:32

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,488
Website

Re: tomcat8 compiled by a non-default version of java

tomcat will only support the oldest version of java in the repo.  Anything older and you will need to recompile it yourself - just reinstalling achieves nothing.

Offline

#3 2024-07-15 07:31:28

cryptearth
Member
Registered: 2024-02-03
Posts: 1,216

Re: tomcat8 compiled by a non-default version of java

java class file version 61 refers to java17 - so you need at least java17 to run it
if, for some reason, you rely on a feature that got broken with the transition from java8 to java9 (most likely something related to jigsaw) you should upgrade your code to modern standards instead of try to drag along java8

Last edited by cryptearth (2024-07-15 07:31:56)

Offline

Board footer

Powered by FluxBB