I am upgrading my application to Micronaut 4 and after I made the changes as described in the Micronaut guide
The application starts-up properly but when I try to retrieve data from a SQL Server I am getting the error:
Exception in thread "DefaultDispatcher-worker-1" io.micronaut.context.exceptions.ConfigurationException: No backing TransactionOperations configured. Check your configuration and try again
Caused by: io.micronaut.context.exceptions.NoSuchBeanException: No bean of type [io.micronaut.transaction.TransactionOperations] exists. Make sure the bean is not disabled by bean requirements (enable trace logging for 'io.micronaut.context.condition' to check) and if the bean is enabled then ensure the class is declared a bean and annotation processing is enabled (for Java and Kotlin the 'micronaut-inject-java' dependency should be configured as an annotation processor).
at io.micronaut.context.DefaultBeanContext.newNoSuchBeanException(DefaultBeanContext.java:2773)
at io.micronaut.context.DefaultApplicationContext.newNoSuchBeanException(DefaultApplicationContext.java:304)
at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2735)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1729)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:856)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:841)
at io.micronaut.transaction.support.DefaultTransactionOperationsRegistry.provideSynchronous(DefaultTransactionOperationsRegistry.java:49)
The method that is causing the issue is like:
@jakarta.transaction.Transactional
fun loadIndex(index: String) = runBlocking {
logger.info { "Starting load..." }
loadRepository.pullLoadRecords()
}
I have declared the datasources in the application.yaml file as usual and also the application used to work perfectly before the upgrade so I am guessing I am doing something wrong with the Micronaut 4 upgrade.
Any suggestions?
The solution was to add the library:
io.micronaut.data:micronaut-data-tx-jdbc
which provides the implementation class of TransactionOperatios that was missing.