Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

org.apache.camel.NoSuchBeanException: No bean could be found in the registry for: servlet of type: org.apache.camel.spi.RestConsumerFactory #7071

Open
ChiranjeeviGithub opened this issue Jun 20, 2018 · 0 comments

Comments

@ChiranjeeviGithub
Copy link

Hi Sir,

I am learning Apache camel Rest expose with spring boot application. i am facing below issue while start the application.
org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route route1: Route(route1)[[From[rest:get:/hello?routeId=route1&component... because of No bean could be found in the registry for: servlet of type: org.apache.camel.spi.RestConsumerFactory
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1830) ~[camel-core-2.21.1.jar:2.21.1]
at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:136) ~[camel-spring-2.21.1.jar:2.21.1]
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:174) ~[camel-spring-2.21.1.jar:2.21.1]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144) ~[spring-boot-1.5.15.BUILD-SNAPSHOT.jar:1.5.15.BUILD-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.15.BUILD-SNAPSHOT.jar:1.5.15.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.15.BUILD-SNAPSHOT.jar:1.5.15.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.15.BUILD-SNAPSHOT.jar:1.5.15.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.15.BUILD-SNAPSHOT.jar:1.5.15.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.15.BUILD-SNAPSHOT.jar:1.5.15.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.15.BUILD-SNAPSHOT.jar:1.5.15.BUILD-SNAPSHOT]
at com.oup.CamelOupApplication.main(CamelOupApplication.java:14) [classes/:na]
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route route1: Route(route1)[[From[rest:get:/hello?routeId=route1&component... because of No bean could be found in the registry for: servlet of type: org.apache.camel.spi.RestConsumerFactory
at org.apache.camel.impl.RouteService.warmUp(RouteService.java:147) ~[camel-core-2.21.1.jar:2.21.1]
at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:3949) ~[camel-core-2.21.1.jar:2.21.1]
at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3856) ~[camel-core-2.21.1.jar:2.21.1]
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3642) ~[camel-core-2.21.1.jar:2.21.1]
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3494) ~[camel-core-2.21.1.jar:2.21.1]
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:209) ~[camel-core-2.21.1.jar:2.21.1]
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3253) ~[camel-core-2.21.1.jar:2.21.1]
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3249) ~[camel-core-2.21.1.jar:2.21.1]
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3272) ~[camel-core-2.21.1.jar:2.21.1]
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3249) ~[camel-core-2.21.1.jar:2.21.1]
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) ~[camel-core-2.21.1.jar:2.21.1]
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:3165) ~[camel-core-2.21.1.jar:2.21.1]
at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:133) ~[camel-spring-2.21.1.jar:2.21.1]
... 16 common frames omitted
Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in the registry for: servlet of type: org.apache.camel.spi.RestConsumerFactory
at org.apache.camel.component.rest.RestEndpoint.createConsumer(RestEndpoint.java:406) ~[camel-core-2.21.1.jar:2.21.1]
at org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDrivenConsumerRoute.java:69) ~[camel-core-2.21.1.jar:2.21.1]
at org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.java:103) ~[camel-core-2.21.1.jar:2.21.1]
at org.apache.camel.impl.RouteService.doWarmUp(RouteService.java:172) ~[camel-core-2.21.1.jar:2.21.1]
at org.apache.camel.impl.RouteService.warmUp(RouteService.java:145) ~[camel-core-2.21.1.jar:2.21.1]
... 28 common frames omitted

Simple Code :
/**
*
*/
package com.oup.routers;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.rest.RestBindingMode;
import org.springframework.stereotype.Component;

import com.oup.model.Book;

/**

*/
@component
public class BookRouter extends RouteBuilder {

/* (non-Javadoc)
 * @see org.apache.camel.builder.RouteBuilder#configure()
 */
@Override
public void configure() throws Exception {
	 restConfiguration()
      .component("servlet")
      .bindingMode(RestBindingMode.json);
	 
	   rest().get("/hello")
	      .to("direct:hello");
}

}

BookService.java
/**
*
*/
package com.oup.services;

import org.springframework.stereotype.Component;

/**

*/
@component
public class BookService {

public String getBook(){
	return "Welcome";
	
}

}
Book.java
/**
*
*/
package com.oup.model;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

import org.springframework.stereotype.Component;

/**

*/
@component
@XmlRootElement(name="Book")
@XmlAccessorType(XmlAccessType.FIELD)
public class Book {

@XmlAttribute
private String name;
@XmlAttribute
private String author;
@XmlAttribute
private String publisher;

public Book(){
	
}

public Book(String name,String author,String publisher){
	this.name= name;
	this.author = author;
	this.publisher = publisher;
}
public String getName() {
	return name;
}
public void setName(String name) {
	this.name = name;
}
public String getAuthor() {
	return author;
}
public void setAuthor(String author) {
	this.author = author;
}
public String getPublisher() {
	return publisher;
}
public void setPublisher(String publisher) {
	this.publisher = publisher;
}

}
SpringBootClass:
package com.oup;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@componentscan
public class CamelOupApplication extends SpringBootServletInitializer {

public static void main(String[] args) {
	SpringApplication.run(CamelOupApplication.class, args);
	  
    }

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
	return builder.sources(CamelOupApplication.class);
}

}

Please help on this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant