Search code examples
javaapache-camelquarkus

Camel- Quarkus: No bean could be found in the registry for: servlet of type: org.apache.camel.spi.RestApiConsumerFactory


I'm trying to get a simple Quarkus/Camel app going, and have hit a snag. I just keep getting the same error:

No bean could be found in the registry for: servlet of type: org.apache.camel.spi.RestApiConsumerFactory

Googling comes up pretty sparce, unsure where to go from here.

Camel dependencies:

<dependency>

            <groupId>org.apache.camel.quarkus</groupId>

            <artifactId>camel-quarkus-core</artifactId>

        </dependency>

        <dependency>

            <groupId>org.apache.camel.quarkus</groupId>

            <artifactId>camel-quarkus-rest</artifactId>

        </dependency>

        <dependency>

            <groupId>org.apache.camel.quarkus</groupId>

            <artifactId>camel-quarkus-direct</artifactId>

        </dependency>

        <dependency>

            <groupId>org.apache.camel.quarkus</groupId>

            <artifactId>camel-quarkus-jackson</artifactId>

        </dependency>

        <dependency>

            <groupId>org.apache.camel.quarkus</groupId>

            <artifactId>camel-quarkus-mock</artifactId>

        </dependency>

Route Setup

public class RestRoute extends RouteBuilder {


    @Override

    public void configure() throws Exception {

        restConfiguration()

        .component("servlet")

        .bindingMode(RestBindingMode.json)

        .dataFormatProperty("prettyPrint", "true")

        .apiContextPath("/api-doc")

        .apiProperty("api.title", "REST API").apiProperty("api.version", "1.0")

        .apiProperty("cors", "true");

        

        rest("/")

                .consumes("application/json")

                .produces("application/json")

                .get()

                .outType(TestObj.class)

                .to("direct:getTestObj");

        

        from("direct:getTestObj")

            .transform()

            .constant(

                TestObj.builder().fieldOne("Hello").fieldTwo("World").build()

            );

    }

}

When .component("servlet") is removed, I get the following error:

java.lang.IllegalStateException: Cannot find RestApiProcessorFactory in Registry or classpath (such as the camel-openapi-java component)


Solution

  • Java have different app and web servers like netty , jetty tomcat , glassfish etc. spring use tomcat in default and tomcat is a servlet implementation therefore spring has servlet classes , quarkus not use tomcat therefore quarkus dont have servlet , quarkus use vert.x and in background vert.x use netty. u must remove explicity component definition just delete it

     .component("servlet")