Springframework : PermittedSubclasses requires ASM8/9
Asked Answered
P

3

7

I have updated the lib and dependency of my project including :

  1. From OpenJDK 11 to OpenJDK 17.0.2
  2. From JavaEE to Jakarta 9
  3. From Springboot 2.7.4 to 3.0.1

The application can be built successfully, and I try to deploy it to Payara Server 6.2022.2 that running OpenJDK 17. However, the following errors are kept throwing and Spring cannot be started.

I have confirmed that the Springboot is the latest version and supports Java 17 environment. Is there any dependency missing?

My pom.xml :

<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.0.1</version>
    <relativePath/> 
</parent>
<version>1.0</version>
<packaging>war</packaging>

<properties>
    <java.version>17</java.version>
    <maven.compiler.source>17</maven.compiler.source>
    <maven.compiler.target>17</maven.compiler.target>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <artifactId>tomcat-embed-logging-juli</artifactId>
                <groupId>org.apache.tomcat.embed</groupId>
            </exclusion>
            <exclusion>
                <artifactId>tomcat-embed-websocket</artifactId>
                <groupId>org.apache.tomcat.embed</groupId>
            </exclusion>
            <exclusion>
                <artifactId>tomcat-embed-el</artifactId>
                <groupId>org.apache.tomcat.embed</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-autoconfigure</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-loader</artifactId>
    </dependency>     
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-oauth2-resource-server</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-oauth2-jose</artifactId>
    </dependency>
    <dependency>
        <groupId>jakarta.platform</groupId>
        <artifactId>jakarta.jakartaee-api</artifactId>
        <version>9.0.0</version>
        <type>jar</type>
    </dependency>
</dependencies>

The content of module-info

requires jakarta.jakartaee.api;
requires spring.beans;
requires spring.boot;
requires spring.boot.loader;
requires spring.boot.autoconfigure;
requires spring.context;
requires spring.core;
requires spring.security.config;
requires spring.security.core;
requires spring.security.web;
requires spring.web;

The Application Class :

import com.xyz.web.application.resources.env;
import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.SpringBootApplication; 
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

@SpringBootApplication 
@EnableConfigurationProperties(env.class)
public class Application extends SpringBootServletInitializer {
        
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}

The log of Payara Server :

SEVERE: Exception while visiting org/springframework/beans/factory/aot/BeanRegistrationsAotContribution$Registration.class of size 2202 java.lang.UnsupportedOperationException: Record requires ASM8 at org.objectweb.asm.ClassVisitor.visitRecordComponent(ClassVisitor.java:305) at org.objectweb.asm.ClassReader.readRecordComponent(ClassReader.java:953) at org.objectweb.asm.ClassReader.accept(ClassReader.java:731) at org.objectweb.asm.ClassReader.accept(ClassReader.java:424) at org.glassfish.hk2.classmodel.reflect.Parser$5.on(Parser.java:336) at com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.handleEntry(ReadableArchiveScannerAdapter.java:164) at com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.onSelectedEntries(ReadableArchiveScannerAdapter.java:130) at org.glassfish.hk2.classmodel.reflect.Parser.doJob(Parser.java:321) at org.glassfish.hk2.classmodel.reflect.Parser.access$300(Parser.java:44) at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:280) at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:269) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833)

SEVERE: Exception while visiting org/springframework/boot/cloud/CloudPlatform.class of size 3703 java.lang.UnsupportedOperationException: PermittedSubclasses requires ASM9 at org.objectweb.asm.ClassVisitor.visitPermittedSubclass(ClassVisitor.java:266) at org.objectweb.asm.ClassReader.accept(ClassReader.java:706) at org.objectweb.asm.ClassReader.accept(ClassReader.java:424) at org.glassfish.hk2.classmodel.reflect.Parser$5.on(Parser.java:336) at com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.handleEntry(ReadableArchiveScannerAdapter.java:164) at com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.onSelectedEntries(ReadableArchiveScannerAdapter.java:130) at org.glassfish.hk2.classmodel.reflect.Parser.doJob(Parser.java:321) at org.glassfish.hk2.classmodel.reflect.Parser.access$300(Parser.java:44) at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:280) at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:269) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833)

SEVERE: Exception while visiting org/springframework/boot/context/config/ConfigDataNotFoundAction.class of size 1750 java.lang.UnsupportedOperationException: PermittedSubclasses requires ASM9 at org.objectweb.asm.ClassVisitor.visitPermittedSubclass(ClassVisitor.java:266) at org.objectweb.asm.ClassReader.accept(ClassReader.java:706) at org.objectweb.asm.ClassReader.accept(ClassReader.java:424) at org.glassfish.hk2.classmodel.reflect.Parser$5.on(Parser.java:336) at com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.handleEntry(ReadableArchiveScannerAdapter.java:164) at com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.onSelectedEntries(ReadableArchiveScannerAdapter.java:130) at org.glassfish.hk2.classmodel.reflect.Parser.doJob(Parser.java:321) at org.glassfish.hk2.classmodel.reflect.Parser.access$300(Parser.java:44) at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:280) at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:269) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833)

SEVERE: Exception while visiting org/springframework/boot/jdbc/DatabaseDriver.class of size 9179 java.lang.UnsupportedOperationException: PermittedSubclasses requires ASM9 at org.objectweb.asm.ClassVisitor.visitPermittedSubclass(ClassVisitor.java:266) at org.objectweb.asm.ClassReader.accept(ClassReader.java:706) at org.objectweb.asm.ClassReader.accept(ClassReader.java:424) at org.glassfish.hk2.classmodel.reflect.Parser$5.on(Parser.java:336) at com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.handleEntry(ReadableArchiveScannerAdapter.java:164) at com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.onSelectedEntries(ReadableArchiveScannerAdapter.java:130) at org.glassfish.hk2.classmodel.reflect.Parser.doJob(Parser.java:321) at org.glassfish.hk2.classmodel.reflect.Parser.access$300(Parser.java:44) at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:280) at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:269) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833)

SEVERE: Exception while visiting org/springframework/boot/convert/DurationStyle.class of size 3821 java.lang.UnsupportedOperationException: PermittedSubclasses requires ASM9 at org.objectweb.asm.ClassVisitor.visitPermittedSubclass(ClassVisitor.java:266) at org.objectweb.asm.ClassReader.accept(ClassReader.java:706) at org.objectweb.asm.ClassReader.accept(ClassReader.java:424) at org.glassfish.hk2.classmodel.reflect.Parser$5.on(Parser.java:336) at com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.handleEntry(ReadableArchiveScannerAdapter.java:164) at com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.onSelectedEntries(ReadableArchiveScannerAdapter.java:130) at org.glassfish.hk2.classmodel.reflect.Parser.doJob(Parser.java:321) at org.glassfish.hk2.classmodel.reflect.Parser.access$300(Parser.java:44) at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:280) at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:269) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833)

SEVERE: Exception while visiting org/springframework/boot/convert/PeriodStyle.class of size 3986 java.lang.UnsupportedOperationException: PermittedSubclasses requires ASM9 at org.objectweb.asm.ClassVisitor.visitPermittedSubclass(ClassVisitor.java:266) at org.objectweb.asm.ClassReader.accept(ClassReader.java:706) at org.objectweb.asm.ClassReader.accept(ClassReader.java:424) at org.glassfish.hk2.classmodel.reflect.Parser$5.on(Parser.java:336) at com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.handleEntry(ReadableArchiveScannerAdapter.java:164) at com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.onSelectedEntries(ReadableArchiveScannerAdapter.java:130) at org.glassfish.hk2.classmodel.reflect.Parser.doJob(Parser.java:321) at org.glassfish.hk2.classmodel.reflect.Parser.access$300(Parser.java:44) at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:280) at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:269) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833)

Packthread answered 28/12, 2022 at 2:29 Comment(2)
Do you have other dependency other than what mentioned in pom.xml?Rask
I have updated the payara version to Payara Server 6.2023.5 and the spring can be started with OpenJDK 17.0.2Packthread
M
6

I had a similar situation while building my Spring Boot 3 project from the command line using Gradle. The solution that worked for me is to upgrade the version of Gradle. I upgraded from 7.2 to 7.6 and that solved the ASM9 issue.

See the line starting with distributionUrl in gradle-wrapper.properties, located in gradle/wrapper:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Multifold answered 13/4, 2023 at 11:29 Comment(0)
D
1

I thought I had answered this already. Glassfish and Payara are using older versions of ASM and CDI. Until they upgrade their distributions, we're stuck migrating to Java 17 and Jakarta.

Darfur answered 14/4, 2023 at 13:55 Comment(2)
Which versions of ASM and CDI is GlassFish using, and which newer versions of both these two are available?Algol
I upgrade to latest version of payara (the version released in May 2023) and it seem ok now. Thank you very muchPackthread
D
0

I saw a payara release notice that announced that the most recent version of Payara contained ASM 9. For me, thats 1/2 the battle cause SpringWebMvc still needs newer CDI installed as well. I'll pull down payara soon and try again....maybe they fixed CDI too but it wasn't in the release notice.

Darfur answered 20/4, 2023 at 23:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.