Mutiny.Session.withTransaction(...) needs duplicated context
See original GitHub issueDescribe the bug
I am trying to run task with @Scheduled:
@Scheduled(every = "PT5S")
fun start2() {
var setting = vertx.executeBlocking<Setting> {
sf.withTransaction { sess -> sess.find(Setting::class.java, "test")}
.await()
.atMost(Duration.ofSeconds(2))
}
setting.onSuccess { logger.info { it } }
.onFailure { logger.error(it) { it } }
}
And get error about duplicated context needed:
java.lang.IllegalStateException: Can't get the context safety flag: the current context is not a duplicated context
I’m tryed also with no result
@Scheduled(every = "PT5S")
fun start2() {
var setting = vertx.executeBlocking<Setting> {
sf.withSession { session -> sf.withTransaction { sess -> sess.find(Setting::class.java, "test")} }
.await()
.atMost(Duration.ofSeconds(2))
}
setting.onSuccess { logger.info { it } }
.onFailure { logger.error(it) { it } }
}
Without vertx.executeBlocking<Setting> {} I get error:
The current operation requires a safe (isolated) Vert.x sub-context, but the current context hasn't been flagged as such. You can still use Hibernate Reactive, you just need to avoid using the methods which implicitly require accessing the stateful context, such as MutinySessionFactory#withTransaction and #withSession.
Expected behavior
Mutiy.Session.withTransaction(…) works fine in scheduler
Actual behavior
Error:
java.lang.IllegalStateException: Can't get the context safety flag: the current context is not a duplicated context
How to Reproduce?
No response
Output of uname -a or ver
No response
Output of java -version
jdk 17.0.2
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.7.5 and 2.8.0
Build tool (ie. output of mvnw --version or gradlew --version)
gradle 7.4.1
Additional information
No response
Issue Analytics
- State:
- Created a year ago
- Comments:12 (8 by maintainers)

Top Related StackOverflow Question
no, but it may need 2.9 (main branch)
#25257 has been fixed.