You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm getting the following error when spring context is refreshed with spring-boot-devtools:
java.lang.IllegalStateException: No transaction in context.
at org.jetbrains.exposed.sql.transactions.TransactionManager$Companion.current(TransactionApi.kt:70) ~[exposed-0.10.4.jar:na]
at org.jetbrains.exposed.sql.vendors.DefaultKt.getCurrentDialect(Default.kt:339) ~[exposed-0.10.4.jar:na]
at org.jetbrains.exposed.sql.SchemaUtils.drop(SchemaUtils.kt:189) ~[exposed-0.10.4.jar:na]
at com.alexbezhan.exposeddemo.Init.init(ExposedDemoApplication.kt:43) ~[classes/:na]
The issue occurs when I provide Exposed Table as a Spring Bean like this:
interface Repository
object Table : IntIdTable(), Repository
// and then in configuration:
@Bean
fun repo(): Repository = Table
And then I drop the table with SchemaUtils on ContextRefreshedEvent:
SchemaUtils.drop(Table)
Here is the minimal code to reproduce:
@EnableTransactionManagement
@SpringBootApplication
class ExposedDemoApplication {
// this causes error after context refresh with spring devtools
@Bean
fun repo(): Repository = Table
@Bean
fun springTransactionManager(dataSource: DataSource): SpringTransactionManager =
SpringTransactionManager(dataSource)
}
interface Repository
object Table : IntIdTable(), Repository
@Transactional
@Component
class Init {
@EventListener
fun init(event: ContextRefreshedEvent) {
println("Init()")
SchemaUtils.drop(Table)
SchemaUtils.create(Table)
}
}
fun main(args: Array<String>) {
runApplication<ExposedDemoApplication>(*args)
}
If I don't provide Table as a Bean, then no exception is thrown.
I also created demo project that reproduces the issue.
The text was updated successfully, but these errors were encountered:
@alexbezhan, Look similar to #407, but I can't reproduce that exception even with your demo project.
Could you please check if the workaround from this comment and the next one will help?
I'm getting the following error when spring context is refreshed with
spring-boot-devtools
:The issue occurs when I provide Exposed Table as a Spring Bean like this:
And then I drop the table with
SchemaUtils
onContextRefreshedEvent
:Here is the minimal code to reproduce:
If I don't provide Table as a Bean, then no exception is thrown.
I also created demo project that reproduces the issue.
The text was updated successfully, but these errors were encountered: