Java. Lang. Illegalargumentexception: Unsupported Class File Major Version 59

I am working on my first project with Java restful webservices, but I am running into some issues. When I run the server with Tomcat and type the url of the GET service, I get a HTTP Status 500 – Internal Server Error. I did research for hours but cannot find anything. Maybe there is some issue in the pom.xml.

Below some code:

ResourceConfig:

package nl.hu.bep.IPASS.Config;

import javax.ws.rs.ApplicationPath;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature;

@ApplicationPath("/restservices")
public class JerseyConfig extends ResourceConfig {

    public JerseyConfig(){
        packages("nl.hu.bep.IPASS.webservices");


    }
}

Resource code:

import nl.hu.bep.IPASS.model.Product;
import nl.hu.bep.IPASS.model.ProductBeheer;


import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

@Path("/producten")
public class ProductResource {
    @GET
    @Produces("application/json")
    public Response getProducten(){
        ProductBeheer beheer = ProductBeheer.getInstance();

        return Response.ok(beheer.getAlleProducten()).build();

    }

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="" xmlns:xsi=""
  xsi:schemaLocation=" ">
  <modelVersion>4.0.0</modelVersion>

  <groupId>nl.hu.bep.IPASS</groupId>
  <artifactId>SD_IPASS_2021</artifactId>
  <version>1.0</version>
  <packaging>war</packaging>

  <name>SD_IPASS_2021</name>


  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>15</maven.compiler.source>
    <maven.compiler.target>15</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.glassfish</groupId>
      <artifactId>javax.json</artifactId>
      <version>1.0.4</version>
    </dependency>
    <dependency>
      <groupId>org.glassfish.jersey.inject</groupId>
      <artifactId>jersey-hk2</artifactId>
      <version>2.30.1</version>
    </dependency>
    <dependency>
      <groupId>org.glassfish.jersey.containers</groupId>
      <artifactId>jersey-container-servlet</artifactId>
      <version>2.30.1</version>
    </dependency>
    <dependency>
      <groupId>org.glassfish.jersey.media</groupId>
      <artifactId>jersey-media-json-jackson</artifactId>
      <version>2.30.1</version>
    </dependency>
    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <version>42.2.20</version>
    </dependency>
    <dependency>
      <groupId>io.jsonwebtoken</groupId>
      <artifactId>jjwt</artifactId>
      <version>0.9.1</version>
    </dependency>


    <dependency>
      <groupId>com.azure</groupId>
      <artifactId>azure-storage-blob</artifactId>
      <version>12.6.0</version>
    </dependency>




    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>5.6.3</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>4.0.1</version>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
      <plugins>
        <!-- clean lifecycle, see  -->

        <plugin>
          <artifactId>maven-war-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.22.1</version>
        </plugin>


      </plugins>
    </pluginManagement>
  </build>
</project>

error:

Screenshot Error

Can someone help me please?

2

1 Answer

You've made class files that cannot be read by JDK14 and downwards; you need at least JDK15. That's what '59' means (it's the class file format version emitted by JDK15).

You have two options:

Downgrade

<maven.compiler.source>15</maven.compiler.source> - make this a lower version, at least as low as the version of the JDK you installed on your server.

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.