java.lang.IllegalArgumentException: Unsupported class file major version 58
Asked Answered
H

1

5

I have included TomEE with Eclipse in order to start developing dynamic web projects (I am still new to it).

Before adding the project to the TomEE server, I am able to start it without any problem.

But when I add the project to the server and try to run it I get the error: java.lang.IllegalArgumentException: Unsupported class file major version 58

What I tried to do in order to solve it:

  • Changing the server port number
  • Deleting and recreating the server
  • Checking the web.xml file to make sure the servlet mapping is fine
  • Reconfiguring the project's target runtime
  • Reconfiguring the runtime environments of eclipse

Versions:

  • TomEE: v8.0.3 plume
  • JDK: 15.0.1
  • Eclipse: 4.17.0

Code of the test project

TestServlet.java

package my.test.project;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class TestServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/plain");
        PrintWriter out = response.getWriter();
        out.println("Hello this is a test");
        out.close();
    }
}

Web.xml

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    version="3.1">
    <servlet>
        <servlet-name>TestServlet</servlet-name>
        <servlet-class>my.test.project.TestServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>TestServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>

Error in console log after executing

Nov 06, 2020 1:06:18 PM jdk.internal.reflect.NativeMethodAccessorImpl invoke
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/TestProject]]
    at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:633)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:343)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:474)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/TestProject]]
    at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
    ... 21 more
Caused by: org.apache.tomee.catalina.TomEERuntimeException: org.apache.openejb.OpenEJBException: Unable to create annotation scanner for web module TestProject: Unable to read class definition for my.test.project.TestServlet
    at org.apache.tomee.catalina.TomcatWebAppBuilder.loadApplication(TomcatWebAppBuilder.java:2363)
    at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1198)
    at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1131)
    at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:134)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5052)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    ... 27 more
Caused by: org.apache.openejb.OpenEJBException: Unable to create annotation scanner for web module TestProject: Unable to read class definition for my.test.project.TestServlet
    at org.apache.openejb.config.DeploymentLoader.addWebModule(DeploymentLoader.java:886)
    at org.apache.openejb.config.DeploymentLoader.load(DeploymentLoader.java:233)
    at org.apache.tomee.catalina.TomcatWebAppBuilder.loadApplication(TomcatWebAppBuilder.java:2361)
    ... 33 more
Caused by: java.lang.RuntimeException: Unable to read class definition for my.test.project.TestServlet
    at org.apache.xbean.finder.AnnotationFinder.readClassDef(AnnotationFinder.java:1180)
    at org.apache.xbean.finder.AnnotationFinder.<init>(AnnotationFinder.java:153)
    at org.apache.xbean.finder.AnnotationFinder.<init>(AnnotationFinder.java:166)
    at org.apache.openejb.config.FinderFactory$OpenEJBAnnotationFinder.<init>(FinderFactory.java:546)
    at org.apache.openejb.config.FinderFactory.newFinder(FinderFactory.java:267)
    at org.apache.openejb.config.FinderFactory.create(FinderFactory.java:80)
    at org.apache.openejb.config.FinderFactory.createFinder(FinderFactory.java:69)
    at org.apache.openejb.config.DeploymentLoader.addWebModule(DeploymentLoader.java:878)
    ... 35 more
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 58
    at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:195)
    at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:176)
    at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:162)
    at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:283)
    at org.apache.xbean.finder.AnnotationFinder.readClassDef(AnnotationFinder.java:1176)
    ... 42 more

Nov 06, 2020 1:06:18 PM jdk.internal.reflect.NativeMethodAccessorImpl invoke
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: A child container failed during start
    at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:633)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:343)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:474)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:928)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
    ... 13 more
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/TestProject]]
    at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
    ... 21 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/TestProject]]
    at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
    ... 21 more
Caused by: org.apache.tomee.catalina.TomEERuntimeException: org.apache.openejb.OpenEJBException: Unable to create annotation scanner for web module TestProject: Unable to read class definition for my.test.project.TestServlet
    at org.apache.tomee.catalina.TomcatWebAppBuilder.loadApplication(TomcatWebAppBuilder.java:2363)
    at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1198)
    at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1131)
    at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:134)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5052)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    ... 27 more
Caused by: org.apache.openejb.OpenEJBException: Unable to create annotation scanner for web module TestProject: Unable to read class definition for my.test.project.TestServlet
    at org.apache.openejb.config.DeploymentLoader.addWebModule(DeploymentLoader.java:886)
    at org.apache.openejb.config.DeploymentLoader.load(DeploymentLoader.java:233)
    at org.apache.tomee.catalina.TomcatWebAppBuilder.loadApplication(TomcatWebAppBuilder.java:2361)
    ... 33 more
Caused by: java.lang.RuntimeException: Unable to read class definition for my.test.project.TestServlet
    at org.apache.xbean.finder.AnnotationFinder.readClassDef(AnnotationFinder.java:1180)
    at org.apache.xbean.finder.AnnotationFinder.<init>(AnnotationFinder.java:153)
    at org.apache.xbean.finder.AnnotationFinder.<init>(AnnotationFinder.java:166)
    at org.apache.openejb.config.FinderFactory$OpenEJBAnnotationFinder.<init>(FinderFactory.java:546)
    at org.apache.openejb.config.FinderFactory.newFinder(FinderFactory.java:267)
    at org.apache.openejb.config.FinderFactory.create(FinderFactory.java:80)
    at org.apache.openejb.config.FinderFactory.createFinder(FinderFactory.java:69)
    at org.apache.openejb.config.DeploymentLoader.addWebModule(DeploymentLoader.java:878)
    ... 35 more
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 58
    at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:195)
    at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:176)
    at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:162)
    at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:283)
    at org.apache.xbean.finder.AnnotationFinder.readClassDef(AnnotationFinder.java:1176)
    ... 42 more

Nov 06, 2020 1:06:18 PM jdk.internal.reflect.NativeMethodAccessorImpl invoke
SEVERE: The required Server component failed to start so Tomcat is unable to start.
org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:928)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:633)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:343)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:474)
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: A child container failed during start
    at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
    ... 13 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:928)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
    ... 13 more
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/TestProject]]
    at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
    ... 21 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/TestProject]]
    at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
    ... 21 more
Caused by: org.apache.tomee.catalina.TomEERuntimeException: org.apache.openejb.OpenEJBException: Unable to create annotation scanner for web module TestProject: Unable to read class definition for my.test.project.TestServlet
    at org.apache.tomee.catalina.TomcatWebAppBuilder.loadApplication(TomcatWebAppBuilder.java:2363)
    at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1198)
    at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1131)
    at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:134)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5052)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    ... 27 more
Caused by: org.apache.openejb.OpenEJBException: Unable to create annotation scanner for web module TestProject: Unable to read class definition for my.test.project.TestServlet
    at org.apache.openejb.config.DeploymentLoader.addWebModule(DeploymentLoader.java:886)
    at org.apache.openejb.config.DeploymentLoader.load(DeploymentLoader.java:233)
    at org.apache.tomee.catalina.TomcatWebAppBuilder.loadApplication(TomcatWebAppBuilder.java:2361)
    ... 33 more
Caused by: java.lang.RuntimeException: Unable to read class definition for my.test.project.TestServlet
    at org.apache.xbean.finder.AnnotationFinder.readClassDef(AnnotationFinder.java:1180)
    at org.apache.xbean.finder.AnnotationFinder.<init>(AnnotationFinder.java:153)
    at org.apache.xbean.finder.AnnotationFinder.<init>(AnnotationFinder.java:166)
    at org.apache.openejb.config.FinderFactory$OpenEJBAnnotationFinder.<init>(FinderFactory.java:546)
    at org.apache.openejb.config.FinderFactory.newFinder(FinderFactory.java:267)
    at org.apache.openejb.config.FinderFactory.create(FinderFactory.java:80)
    at org.apache.openejb.config.FinderFactory.createFinder(FinderFactory.java:69)
    at org.apache.openejb.config.DeploymentLoader.addWebModule(DeploymentLoader.java:878)
    ... 35 more
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 58
    at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:195)
    at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:176)
    at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:162)
    at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:283)
    at org.apache.xbean.finder.AnnotationFinder.readClassDef(AnnotationFinder.java:1176)
    ... 42 more

Nov 06, 2020 1:06:18 PM jdk.internal.reflect.DelegatingMethodAccessorImpl invoke
INFO: Pausing ProtocolHandler ["http-nio-8080"]
Nov 06, 2020 1:06:18 PM jdk.internal.reflect.DelegatingMethodAccessorImpl invoke
INFO: Stopping service [Catalina]
Nov 06, 2020 1:06:18 PM org.apache.openejb.server.SimpleServiceManager stop
INFO: Stopping server services
Nov 06, 2020 1:06:18 PM jdk.internal.reflect.DelegatingMethodAccessorImpl invoke
INFO: Destroying ProtocolHandler ["http-nio-8080"]

Project Facets

Project Facets

The help would be very much appreciated as I've been at it for quite some time but can't seem to figure out what the problem is.

Thank you.

Hendershot answered 6/11, 2020 at 11:14 Comment(3)
The error indicates the different Java versions used (probably by your build tool / Eclipse / TomEE).Retiring
You are trying to run code compiled for Java 14 (class file version 58) on an older version of JavaCustomable
Does this answer your question? How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor versionBartholomew
T
6

You have mentioned your version is JDK: 15.0.1 and the project's Java Facet is 14.

FYI:

  • Java 13 uses major version 57
  • Java 14 uses major version 58
  • Java 15 uses major version 59
  • Java 16 uses major version 60

The version can be checked with:

javap -verbose MyClass | grep "major"
Trimerous answered 6/11, 2020 at 13:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.