Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict with spring load time weaving #853

Closed
jameswangz opened this issue Jan 11, 2022 · 2 comments
Closed

Conflict with spring load time weaving #853

jameswangz opened this issue Jan 11, 2022 · 2 comments

Comments

@jameswangz
Copy link

jameswangz commented Jan 11, 2022

Hi, I want to use spring load time weaving and shedlock together but the app failed to start, my configuration is:

@Configuration
@EnableAsync
@EnableJpaAuditing
@EnableScheduling
@EnableSchedulerLock(defaultLockAtMostFor = "10m")
@EnableLoadTimeWeaving(aspectjWeaving = EnableLoadTimeWeaving.AspectJWeaving.ENABLED)
@EnableConfigurationProperties(value = { CustomConfig.class, MasterSlaveDataSourceConfig.class})
public class ApplicationConfig {

}

When the app starts, it reports error:

2022-01-12 01:16:27.525 DEBUG 53146 --- [  restartedMain] org.springframework.beans.factory.support.DefaultListableBeanFactory : Creating shared instance of singleton bean 'org.springframework.transaction.config.internalTransactionalEventListenerFactory'
2022-01-12 01:16:27.543 ERROR 53146 --- [  restartedMain] org.springframework.boot.SpringApplication : Application run failed

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 @481a15ff
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
	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.Method.setAccessible(Method.java:193)
	at org.springframework.util.ReflectionUtils.makeAccessible(ReflectionUtils.java:573)
	at org.springframework.context.support.ContextTypeMatchClassLoader$ContextOverridingClassLoader.isEligibleForOverriding(ContextTypeMatchClassLoader.java:99)
	at org.springframework.core.OverridingClassLoader.loadClass(OverridingClassLoader.java:87)

I tried to remove the EnableLoadTimeWeaving config then the app can start successfully, I searched the error and added the following java vm options and it still doesn't work:

bootRun {
	args = ['--add-opens java.base/java.lang=ALL-UNNAMED']
	jvmArgs += [ '-javaagent:' + projectDir + '/lib/spring-instrument-5.3.10.jar']
}

The lib versions I'm using are:

Java 16
SpringBoot 2.5.6
ShedLock 4.30.0

@lukas-krecan
Copy link
Owner

Hi, thanks for feedback. This seems to be more general problem with Spring AOP, Java 9+ and loadtime waving spring-projects/spring-framework#22791

@jameswangz
Copy link
Author

Thanks Lukas, but I found if I don't use @EnableSchedulerLock the load time weaving function can work correctly, if I remove @EnableLoadTimeWeaving then shedlock can work, so I suspect they may have some conflicts but I'm not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants