Hi there,
We use for our microservices Spring Boot and we are migrating from 2.7.10 to 3.1.0-RC1. Unfortunately, we are getting InaccessibleObjectException on the level of beans instantiation, explicitly in the GroovyBeanDefinitionReader class. Although we are not using Groovy in our microservices and we don't require any bean of it for the functioning of our dependencies.
The hacky solution for this exception as we all know is: running the microservice with the --add-unnamed JVM-variable. But for us, this is not sustainable. Thus we are trying to find a solution that solves the problem from its roots.
In the application file, I disabled the setup of the Groovy template by defining the following settings - unfortunately, it didn't help.
groovy:
template:
enabled: false
checkTemplateLocation: false
cache: false
Error Stacktrace:
java.lang.reflect.InaccessibleObjectException: Unable to make protected void java.lang.Object.finalize() throws java.lang.Throwable accessible: module java.base does not "opens java.lang" to unnamed module @6989da5e
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
at java.base/java.lang.reflect.AccessibleObject.setAccessible(AccessibleObject.java:130)
at org.codehaus.groovy.reflection.CachedClass$3$1.run(CachedClass.java:86)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at org.codehaus.groovy.reflection.CachedClass$3.initValue(CachedClass.java:81)
at org.codehaus.groovy.reflection.CachedClass$3.initValue(CachedClass.java:79)
at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
at org.codehaus.groovy.reflection.CachedClass.getMethods(CachedClass.java:250)
at org.codehaus.groovy.reflection.CachedClass$3.initValue(CachedClass.java:116)
at org.codehaus.groovy.reflection.CachedClass$3.initValue(CachedClass.java:79)
at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
at org.codehaus.groovy.reflection.CachedClass.getMethods(CachedClass.java:250)
at org.codehaus.groovy.reflection.CachedClass$3.initValue(CachedClass.java:116)
at org.codehaus.groovy.reflection.CachedClass$3.initValue(CachedClass.java:79)
at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
at org.codehaus.groovy.reflection.CachedClass.getMethods(CachedClass.java:250)
at org.codehaus.groovy.reflection.stdclasses.CachedClosureClass.<init>(CachedClosureClass.java:29)
at org.codehaus.groovy.reflection.ClassInfo.createCachedClass(ClassInfo.java:269)
at org.codehaus.groovy.reflection.ClassInfo.access$400(ClassInfo.java:36)
at org.codehaus.groovy.reflection.ClassInfo$LazyCachedClassRef.initValue(ClassInfo.java:435)
at org.codehaus.groovy.reflection.ClassInfo$LazyCachedClassRef.initValue(ClassInfo.java:426)
at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
at org.codehaus.groovy.reflection.ClassInfo.getCachedClass(ClassInfo.java:89)
at org.codehaus.groovy.reflection.ReflectionCache.getCachedClass(ReflectionCache.java:107)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.registerMethods(MetaClassRegistryImpl.java:189)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:93)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:71)
at groovy.lang.GroovySystem.<clinit>(GroovySystem.java:33)
at org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader.<init>(GroovyBeanDefinitionReader.java:151)
at org.springframework.boot.BeanDefinitionLoader.<init>(BeanDefinitionLoader.java:89)
at org.springframework.boot.SpringApplication.createBeanDefinitionLoader(SpringApplication.java:725)
at org.springframework.boot.SpringApplication.load(SpringApplication.java:668)
at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:413)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:310)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1305)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1294)
at de.patronas.opus.extensions.microservices.tradeblotterexporter.Application.main(Application.java:44)
2023-04-28T11:04:52.855+02:00 ERROR 1266276 --- [ main] o.s.boot.SpringApplication : Application run failed
java.lang.ExceptionInInitializerError: null
Comment From: mohamedbayoudh
We had a transitive dependency in our dependencies which uses Groovy 2.1.3. By upgrading Groovy to 3.1.0 the problem is solved 😄