I have recently migrated my application from spring boot 2.7 to spring boot 3.0. By doing so I've moved from jdk 8 to jdk 17 specifically jdk17 from liberica. I'm using gradle 8.1.0
I'm getting an error when I try to run the application, here is the stack:
10:37:20 AM: Executing ':bootRun --add-opens=java.base/java.lang=ALL-UNNAMED'...
Starting Gradle Daemon...
Gradle Daemon started in 915 ms
> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :resolveMainClassName UP-TO-DATE
> Task :bootRun
...
10:37:29.977 [background-preinit] INFO o.h.validator.internal.util.Version - HV000001: Hibernate Validator 8.0.0.Final
10:37:30.089 [main] INFO lu.legitech.lexnow.Application - Starting Application using Java 17.0.7 with PID 190077 (/home/ccastro/Projects/lexnow/server/build/classes/java/main started by ccastro in /home/ccastro/Projects/lexnow/server)
10:37:30.091 [main] INFO lu.legitech.lexnow.Application - The following 1 profile is active: "local-CCA"
10:37:31.082 [main] INFO o.s.b.c.c.annotation.BatchRegistrar - Finished Spring Batch infrastructure beans configuration in 5 ms.
10:37:31.631 [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Bootstrapping Spring Data JPA repositories in DEFAULT mode.
10:37:32.557 [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 919 ms. Found 83 JPA repository interfaces.
.....
10:37:33.397 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat initialized with port(s): 8763 (https)
10:37:33.406 [main] INFO o.a.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["https-jsse-nio-8763"]
10:37:33.407 [main] INFO o.a.catalina.core.StandardService - Starting service [Tomcat]
10:37:33.407 [main] INFO o.a.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/10.1.8]
10:37:33.481 [main] INFO o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
10:37:33.483 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 3300 ms
10:37:33.983 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
10:37:34.285 [main] INFO com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@776d8097
10:37:34.286 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed.
10:37:34.327 [main] INFO o.h.jpa.internal.util.LogHelper - HHH000204: Processing PersistenceUnitInfo [name: default]
10:37:34.363 [main] INFO org.hibernate.Version - HHH000412: Hibernate ORM core version 6.1.7.Final
10:37:34.628 [main] INFO SQL dialect - HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
....
10:37:36.958 [main] INFO o.h.e.t.j.p.i.JtaPlatformInitiator - HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
10:37:36.965 [main] INFO o.s.o.j.LocalContainerEntityManagerFactoryBean - Initialized JPA EntityManagerFactory for persistence unit 'default'
10:37:37.720 [main] INFO o.s.s.l.p.PasswordPolicyAwareContextSource - Configure with URL ldap://localhost:389/ou=DLEXNOWSTORE,dc=legitech,dc=lu and root DN ou=DLEXNOWSTORE,dc=legitech,dc=lu
10:37:40.870 [main] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bookImportLogWriter' defined in file [/home/ccastro/Projects/lexnow/server/build/classes/java/main/lu/legitech/lexnow/batch/anthemis/BookImportLogWriter.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'allLogFileWriter' defined in BeanDefinition defined in class path resource [lu/legitech/lexnow/configuration/BookImportBatchConfiguration.class]: Could not generate CGLIB subclass of class java.io.FileWriter: Common causes of this problem include using a final class or a non-visible class
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'allLogFileWriter' defined in BeanDefinition defined in class path resource [lu/legitech/lexnow/configuration/BookImportBatchConfiguration.class]: Could not generate CGLIB subclass of class java.io.FileWriter: Common causes of this problem include using a final class or a non-visible class
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'allLogFileWriter' defined in BeanDefinition defined in class path resource [lu/legitech/lexnow/configuration/BookImportBatchConfiguration.class]: Could not generate CGLIB subclass of class java.io.FileWriter: Common causes of this problem include using a final class or a non-visible class
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'errorsLogFileWriter' defined in BeanDefinition defined in class path resource [lu/legitech/lexnow/configuration/BookImportBatchConfiguration.class]: Could not generate CGLIB subclass of class java.io.FileWriter: Common causes of this problem include using a final class or a non-visible class
10:37:40.873 [main] INFO o.s.o.j.LocalContainerEntityManagerFactoryBean - Closing JPA EntityManagerFactory for persistence unit 'default'
10:37:40.874 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown initiated...
10:37:40.876 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown completed.
10:37:40.878 [main] INFO o.a.catalina.core.StandardService - Stopping service [Tomcat]
10:37:40.895 [main] INFO o.s.b.a.l.ConditionEvaluationReportLogger -
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
10:37:40.908 [main] ERROR o.s.boot.SpringApplication - Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bookImportLogWriter' defined in file [/home/ccastro/Projects/lexnow/server/build/classes/java/main/lu/legitech/lexnow/batch/anthemis/BookImportLogWriter.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'allLogFileWriter' defined in BeanDefinition defined in class path resource [lu/legitech/lexnow/configuration/BookImportBatchConfiguration.class]: Could not generate CGLIB subclass of class java.io.FileWriter: Common causes of this problem include using a final class or a non-visible class
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:245)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1352)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1189)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:973)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:917)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:310)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1304)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1293)
at lu.legitech.lexnow.Application.main(Application.java:31)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'allLogFileWriter' defined in BeanDefinition defined in class path resource [lu/legitech/lexnow/configuration/BookImportBatchConfiguration.class]: Could not generate CGLIB subclass of class java.io.FileWriter: Common causes of this problem include using a final class or a non-visible class
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:605)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1417)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)
... 19 common frames omitted
Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class java.io.FileWriter: Common causes of this problem include using a final class or a non-visible class
at org.springframework.aop.framework.CglibAopProxy.buildProxy(CglibAopProxy.java:216)
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:158)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
at org.springframework.aop.scope.ScopedProxyFactoryBean.setBeanFactory(ScopedProxyFactoryBean.java:115)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1791)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1758)
at **org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598)
... 29 common frames omitted
Caused by: org.springframework.cglib.core.ReflectUtils$1: ClassLoader mismatch for [java.io.FileWriter]: JVM should be started with --add-opens=java.base/java.lang=ALL-UNNAMED for ClassLoader.defineClass to be accessible on jdk.internal.loader.ClassLoaders$AppClassLoader
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:529)**
at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:367)
at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:575)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.lambda$new$1(AbstractClassGenerator.java:103)
at org.springframework.cglib.core.internal.LoadingCache.lambda$createEntry$1(LoadingCache.java:52)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:57)
at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:126)
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:313)
at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:562)
at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:407)
at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:62)
at org.springframework.aop.framework.CglibAopProxy.buildProxy(CglibAopProxy.java:213)
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:158)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
at org.springframework.aop.scope.ScopedProxyFactoryBean.setBeanFactory(ScopedProxyFactoryBean.java:115)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1791)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1758)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
at org.springframework.beans.factory.support.AbstractBeanFactory.getTypeForFactoryBean(AbstractBeanFactory.java:1671)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:902)
at org.springframework.beans.factory.support.AbstractBeanFactory.getType(AbstractBeanFactory.java:699)
at org.springframework.beans.factory.support.AbstractBeanFactory.getType(AbstractBeanFactory.java:665)
at org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver.checkQualifier(QualifierAnnotationAutowireCandidateResolver.java:248)
at org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver.checkQualifiers(QualifierAnnotationAutowireCandidateResolver.java:176)
at org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver.isAutowireCandidate(QualifierAnnotationAutowireCandidateResolver.java:149)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.isAutowireCandidate(DefaultListableBeanFactory.java:883)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.isAutowireCandidate(DefaultListableBeanFactory.java:842)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.isAutowireCandidate(DefaultListableBeanFactory.java:825)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1596)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1380)
... 22 common frames omitted
Caused by: java.lang.IllegalAccessException: module java.base does not open java.io to unnamed module @1880a322
at java.base/java.lang.invoke.MethodHandles.privateLookupIn(MethodHandles.java:259)
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:525)
... 57 common frames omitted
> Task :bootRun FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':bootRun'.
> Process 'command '/home/ccastro/.sdkman/candidates/java/17.0.7-librca/bin/java'' finished with non-zero exit value 1
....
BUILD FAILED in 20s
4 actionable tasks: 1 executed, 3 up-to-date
10:37:41 AM: Execution finished ':bootRun --add-opens=java.base/java.lang=ALL-UNNAMED'.
It seems the beans that are causing the error are using java.io.FileWriter and the compiler cannot resolve it.
I try adding as suggested: --add-opens=java.base/java.lang=ALL-UNNAMED' to the java virtual machine but I didn't fixed the problem.
Here is one bean that is causing the issue. It's a bean that is supposed to be used for spring batch.
@StepScope
@Bean(name = "errorsLogFileWriter")
public java.io.FileWriter getErrorsLogFileWriter(
@Value("${application.folders.logs}") String logsFolderPath,
@Value("#{jobParameters[T(lu.legitech.lexnow.batch.anthemis.BatchJobs).JOB_EXECUTION_START]}") Date jobExecutionStart
) throws IOException {
LocalDateTime currentDate = new java.sql.Timestamp(jobExecutionStart.getTime()).toLocalDateTime();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy_MM_dd___HH_mm");
String commonFileNamePart = logsFolderPath + currentDate.format(formatter) + "_import";
return new FileWriter(commonFileNamePart + "_errors.html");
}
Here is how I inject it:
@Qualifier("errorsLogFileWriter")
private final FileWriter errorsLogFileWriter;
Here is a copy of my build.gradle file with all my dependencies:
plugins {
// Apply the java plugin to add support for Java
id 'java'
// Apply the java-library plugin for API and implementation separation.
id 'java-library'
id "org.flywaydb.flyway" version "9.16.3"
// Apply the application plugin to add support for building a CLI application.
id 'application'
id("org.springframework.boot") version "3.0.6"
}
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'lu.legitech'
sourceCompatibility = 17
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
ext {
springBatchVersion = "5.0.1"
testContainersVersion = "1.18.0"
lombokVersion = '1.18.26'
}
dependencies {
implementation("org.jetbrains:annotations:24.0.1")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-mail")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-cache")
implementation("org.springframework.boot:spring-boot-starter-websocket")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-amqp")
implementation("org.springframework.security:spring-security-ldap")
implementation("org.springframework:spring-context-support")
//http client 5 required
implementation 'org.apache.httpcomponents.client5:httpclient5:5.2.1'
implementation 'org.springframework.cloud:spring-cloud-vault-config:4.0.1'
implementation 'org.springframework.vault:spring-vault-core:3.0.2'
// spring-batch
implementation("org.springframework.boot:spring-boot-starter-batch") {
exclude(module: 'spring-batch-infrastructure')
}
implementation("org.springframework.batch:spring-batch-infrastructure:${springBatchVersion}")
// Logger
implementation("ch.qos.logback:logback-classic:1.4.6")
implementation("ch.qos.logback:logback-core:1.4.6")
//implementation("commons-io:commons-io:2.11.0")
implementation("org.apache.commons:commons-compress:1.23.0")
// Json
implementation("org.json:json:20230227")
implementation("com.jayway.jsonpath:json-path:2.8.0")
implementation("io.rest-assured:json-schema-validator:5.3.0")
// Freemarker ftlh templates
implementation('org.freemarker:freemarker:2.3.32')
//HTMl XML parser
implementation("org.jsoup:jsoup:1.15.4")
implementation("net.sourceforge.htmlcleaner:htmlcleaner:2.27")
//PDF Creator
implementation("org.xhtmlrenderer:flying-saucer-pdf-itext5:9.1.22")
implementation('org.apache.pdfbox:pdfbox:2.0.28')
implementation("net.sf.saxon:Saxon-HE:12.1") {
exclude group: "net.sf.saxon", module: "xpath"
}
// https://mvnrepository.com/artifact/com.github.lookfirst/sardine
implementation('com.github.lookfirst:sardine:5.10')
//JACKSON LIBRARY
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.14.2'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.14.2'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.14.2'
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.14.2'
implementation group: 'com.fasterxml.jackson.module', name: 'jackson-module-parameter-names', version: '2.14.2'
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-guava', version: '2.14.2'
implementation group: 'com.fasterxml', name: 'classmate', version: '1.5.1'
// apache commons
implementation("org.apache.commons:commons-lang3:3.12.0")
implementation("org.apache.commons:commons-csv:1.10.0")
implementation("commons-beanutils:commons-beanutils:1.9.4")
implementation 'org.apache.commons:commons-text:1.10.0'
//google
implementation 'com.google.guava:guava:31.1-jre'
//apache excel
implementation 'org.apache.poi:poi-ooxml:5.2.3'
implementation 'org.apache.commons:commons-compress:1.23.0'
//openapi
implementation("org.springdoc:springdoc-openapi-ui:1.7.0")
// Lombok
annotationProcessor('org.springframework.boot:spring-boot-configuration-processor:3.0.5',
"org.projectlombok:lombok:${lombokVersion}")
compileOnly("org.projectlombok:lombok:${lombokVersion}")
testAnnotationProcessor("org.projectlombok:lombok:${lombokVersion}")
testCompileOnly("org.projectlombok:lombok:${lombokVersion}")
testImplementation("org.dbunit:dbunit:2.6.0")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.batch:spring-batch-test")
runtimeOnly("org.postgresql:postgresql:42.6.0")
//Mockito
testImplementation 'org.mockito:mockito-inline:5.2.0'
// testContainers
testImplementation("org.testcontainers:junit-jupiter:${testContainersVersion}")
testImplementation("org.testcontainers:postgresql:${testContainersVersion}")
}
// Apply a specific Java toolchain to ease working on different environments.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
application {
// Define the main class for the application.
mainClass = 'lu.legitech.lexnow.Application'
}
tasks.register('copyResources', Copy) {
from "upload"
into "$buildDir/upload"
}
tasks.named('test') {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
I've tried what is being suggested in these questions but I can't find the solution:
Throwing java.lang.IllegalAccessException module java.base does not open java.util.concurrent when running Corretto on Java https://github.com/spring-projects/spring-framework/issues/22814
Edit:
I'm getting this exception:
Caused by: java.lang.IllegalAccessException: module java.base does not open java.io to unnamed module @1880a322
at java.base/java.lang.invoke.MethodHandles.privateLookupIn(MethodHandles.java:259)
Caused by: java.lang.IllegalAccessException: module java.base does not open java.io to unnamed module @1880a322
Thanks to @Holger and @John Williams and as suggested in https://discuss.gradle.org/t/unrecognized-jvm-option-for-add-opens-gradle-6-and-jdk11/34325/2
I have fixed the issue by adding this configuration to my build.gradle file like so:
application {
// Define the main class for the application.
mainClass = 'App'
applicationDefaultJvmArgs = ['--add-opens', 'java.base/java.lang=ALL-UNNAMED',
'--add-opens', 'java.base/java.util=ALL-UNNAMED',
'--add-opens', 'java.base/java.io=ALL-UNNAMED']
}