0

I have this Java project (branch java11) that I am currently working with.

Today I upgraded from Java 8 to Java 17. I changed some code regarding security, ACLs and the EHCache since many components were deprecated.

My code now compiles, but it has a weird runtime error that I have never seen before:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/ICIQ/eChempad/configurations/database/DatabaseAccessBeans.class]: Cannot apply class transformer without LoadTimeWeaver specified
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1753) ~[spring-beans-6.0.0.jar:6.0.0]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599) ~[spring-beans-6.0.0.jar:6.0.0]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.0.jar:6.0.0]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.0.jar:6.0.0]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.0.jar:6.0.0]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.0.jar:6.0.0]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.0.jar:6.0.0]
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1131) ~[spring-context-6.0.0.jar:6.0.0]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:906) ~[spring-context-6.0.0.jar:6.0.0]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584) ~[spring-context-6.0.0.jar:6.0.0]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.1.2.jar:3.1.2]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-3.1.2.jar:3.1.2]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:436) ~[spring-boot-3.1.2.jar:3.1.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[spring-boot-3.1.2.jar:3.1.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-3.1.2.jar:3.1.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-3.1.2.jar:3.1.2]
        at org.ICIQ.eChempad.EChempadApplication.main(EChempadApplication.java:50) ~[classes/:na]
Caused by: java.lang.IllegalStateException: Cannot apply class transformer without LoadTimeWeaver specified

How can I deactivate Load Time Weaving?

Alternatively, how can I properly configure Load Time Weaving?

I am perhaps seeking an explanation about how Load Time Weaving affects my application. This is a thing that I did not configure so I do not know how to deactivate it.

What I tried is configure the Load Time Weaving with instructions that I found on the Internet such as annotating my main class with @EnableLoadTimeWeaving and adding the dependency of AspectJ but I get this different error:

java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.findLoadedClass(java.lang.String) accessible: module java.base does not "opens java.lang" to unnamed module @1a99ac49

What I am doing wrong? I do not understand what I need to do.

halfer
  • 19,824
  • 17
  • 99
  • 186
Aleix Mariné
  • 110
  • 1
  • 9
  • 1
    Look up the module system introduced in Java 9. – Kayaman Aug 10 '23 at 19:56
  • Why are you making this suggestion? Do you think that using modules will help solve my problem? – Aleix Mariné Aug 10 '23 at 20:06
  • The directive from @Kayaman may be a little brief, but they are directing you to another question, which is suggested as an existing duplicate of your question. Have a look at that link (in the blue box) and see if it describes/solves the problem you have. – halfer Aug 12 '23 at 09:47
  • FYI, I reopened the question and closed it again as a duplicate of another, more AspectJ-specific one than the generic module system one. The problems with having to open a module for Aspectj LTW to work properly started no earlier than Java 16, and the solution is described in my linked answer. – kriegaex Aug 14 '23 at 01:32

0 Answers0