Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@brohacz
Copy link

@brohacz brohacz commented Jan 12, 2023

When using spring-boot-devtools, the application is using two class loaders: Classes that don’t change (for example, those from third-party jars) are loaded into a base classloader. Classes that are under development are loaded into a restart classloader.

DefaultMethodHandler is loaded by the base classloader while the user classes are loaded via restart classloader. When DefaultMethdHandler tries to load the user class (using base classloader) if cannot find it and it results in NoSuchMethodException:

Caused by: java.lang.NoSuchMethodException: com.model.MyEntity$DefaultImpls.toDomain(com.model.MyEntity, org.ktorm.database.Database)
	at java.base/java.lang.Class.getMethod(Class.java:2108)
	at org.ktorm.entity.DefaultMethodHandler$Companion.forMethod$lambda-0(DefaultMethodHandler.kt:119)
	at java.base/java.util.Map.computeIfAbsent(Map.java:1003)
	at java.base/java.util.Collections$SynchronizedMap.computeIfAbsent(Collections.java:2682)
	at org.ktorm.entity.DefaultMethodHandler$Companion.forMethod(DefaultMethodHandler.kt:113)
	at org.ktorm.entity.EntityImplementation.handleMethodCall(EntityImplementation.kt:94)
	at org.ktorm.entity.EntityImplementation.invoke(EntityImplementation.kt:67)
	... 165 more

PR to fix DefaultMethodHandler to load the class using the same classloader as method's declaring class.

@vincentlauvlwj vincentlauvlwj merged commit 1442539 into kotlin-orm:v3.6.x Jan 18, 2023
@vincentlauvlwj
Copy link
Member

Thank you.

@brohacz brohacz deleted the classloader_fix branch February 2, 2023 09:58
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

Successfully merging this pull request may close these issues.

2 participants