No handler found for query

Try to user QueryGateway with following code [koltin]

In controller:


fun queryAllSystem() = monoQueryResult {
    queryGateway.query("queryAll", "",


Query handler:


class SystemQueryHandler {

    private lateinit var systemEntryRepository: SystemEntryRepository

    @QueryHandler(queryName = "queryAll")
    fun queryAll(): List<SystemEntry> {
        return this.systemEntryRepository.findAll()


got exception when do request:


Caused by: org.axonframework.queryhandling.NoHandlerForQueryException: No handler found for queryAll with response type org.axonframework.queryhandling.responsetypes.InstanceResponseType@48e4bf1a
at org.axonframework.queryhandling.SimpleQueryBus.query( ~[axon-core-3.2.jar:3.2]
at org.axonframework.queryhandling.DefaultQueryGateway.query( ~[axon-core-3.2.jar:3.2]
at org.axonframework.queryhandling.QueryGateway.query( ~[axon-core-3.2.jar:3.2]
… 70 common frames omitted


what I know is the response type not matched

how to fix it?


As the second argument to the QueryGateway’s query method, instead of “”, you should use:


with ResponseTypes imported as

import org.axonframework.queryhandling.responsetypes.ResponseTypes

Kind regards,

it works



I have the same issue.

Here is main application:


open class MainApplication {

    companion object {

        fun main(args: Array<String>) {
            var configurableApplicationContext =, *args)

            val queryGateway = configurableApplicationContext.getBean(
            val commandGateway = configurableApplicationContext.getBean(

            commandGateway.sendAndWait<CreateDeviceCmd>(CreateDeviceCmd(UUID.randomUUID().toString(), "WTKSSJJ", 122))

            queryGateway.query(FetchDevicesQuery(2), ResponseTypes.instanceOf(String.javaClass)).get()


And here is query handler:


class DeviceQueryHandler {

    fun handle(query: FetchDevicesQuery): String {
        return "test"



CommandGateway works fine but for some reason QueryHandler is not visible and i’m getting NoHandlerForQueryException for FetchDevicesQuery.

Any tip?


I’m not a Kotlin expert, but to retrieve objects from the application context, you use whereas in the query, you use .javaClass. Could that make a difference?

Also, make sure that the component containing the query handlers is in a package that is scanned by Spring Boot.

Hope this helps.