camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raul Kripalani <r...@evosent.com>
Subject Re: MongoDB endpoint created before beans are being registered when deployed on ServiceMix
Date Wed, 03 Jul 2013 10:17:48 GMT
Just out of curiosity, could you define the Mongo bean in the same Spring
Application Context XML where the Camel Context is configured? (using the
XML config style instead of the Java style).

*Raúl Kripalani*
Enterprise Architect, Open Source Integration specialist, Program
Manager | Apache
Camel Committer
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Wed, Jul 3, 2013 at 9:35 AM, akcameluser <ayache.khettar@gmail.com>wrote:

> Hi
>
> I am getting this weird error stating that Bean can't be found in registry.
> Looks like the mongodb endpoint is being created before  beans are
> registered. I can run it perfectly on IDE and experienced the same issues
> on
> my local ServiceMix but it seems to have gone away now. But the still
> failing on test environment. so this is clearly a random loading orders
> issue. How do I force the beans are registered first before endpoints are
> being created?
>
> I have tried to add: DependsOn() annotation on the Router but stil the
> issue
> persist.
>
> See details of my set up below. Your help is very much appreciated.
>
> *ROUTER*
>
> @DependsOn("mongoBean")
> public class ArchivaQARouter extends ArchivaBaseRouter {
>
>
>     /*
>      * (non-Javadoc)
>      *
>      * @see org.apache.camel.builder.RouteBuilder#configure()
>      */
>     @Override
>     public void configure() throws Exception {
>
>         // Initialise all the properties and set the error handler.
>         super.configure();
>
>         /**
>          *   FTP endpoint
>          */
>         from("{{jetty.qa.endPoint}}").routeId("qa endpoint")//
>                 .process(new Processor() {
>                     @Override
>                     public void process(Exchange exchange) throws Exception
> {
>                         String body = "{ \"doi\": \"" +
> exchange.getIn().getHeader(Constants.DOI) + "\" }";
>                         exchange.setProperty(Constants.QAReport,
> exchange.getIn().getBody());
>                         exchange.getOut().setBody(body);
>                     }
>                 })
>
>                 //.setBody().constant("{ \"doi\": \"" +
> simple("${in.header.doi}") + "\" }")
>                 .to("{{mongodb.endpoint}}") //
>
> mongodb.endpoint=mongodb:mongoBean?database=archiva&collection=submission&operation=findOneByQuery
>
>                 .beanRef("ftpHandler", "handleQAReport")
>                 .to("{{ftp.qa.endpoint}}").id("qa.ftp.endpoint");
>
>     }
> }
>
> *CAMEL CONTEXT
> *
>
> <context:component-scan
> base-package="com.nature.archiva.service.configuration" />
>
>         <context:property-placeholder
> location="file:${karaf.home}/etc/archiva.properties" />
>
>
>
>         <camel:camelContext id="camel">
>                 <camel:template id="template" />
>                 <camel:routeBuilder ref="archivaRouter" />
>                 <camel:routeBuilder ref="archivaBaseRouter" />
>                 <camel:routeBuilder ref="archivaStatusRouter"/>
>         <camel:routeBuilder ref="archivaQARouter"/>
>         <camel:routeBuilder ref="deadLetterChannel" />
>         </camel:camelContext>
>
> ( I tried to define the template in camel-context, but didn't help)
>
> @Configuration
> public class ApplicationContextConfiguration {
>
>         private final Logger log = Logger.getLogger(this.getClass());
>
>         @Bean(name = "marshaller")
>         public Jaxb2Marshaller getMarshaller() {
>                 final Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
>                 marshaller.setClassesToBeBound(Response.class,
> Reports.class,
>                                 Articles.class);
>                 return marshaller;
>         }
>
> /**
>      *
>      * @return
>      * @throws UnknownHostException
>      */
>     @Bean(name = "mongoBean")
>     public Mongo getMongoInstance(@Value("${db.host}") String host) throws
> UnknownHostException {
>         return new Mongo(host);
>     }
> }
>
>
> Stacktrace:
>
> at java.lang.Thread.run(Thread.java:722)
> Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create
> route qa endpoint at: >>>
>
> To[mongodb:mongoBean?database=archiva&collection=submission&operation=findOneByQuery]
> <<< in route: Route[[From[{{jetty.qa.endPoint}}]] ->
> [process[com.nature.a... because of Failed to resolve endpoint:
>
> mongodb://mongoBean?collection=submission&database=archiva&operation=findOneByQuery
> due to: No bean could be found in the registry for: mongoBean of type:
> com.mongodb.Mongo
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/MongoDB-endpoint-created-before-beans-are-being-registered-when-deployed-on-ServiceMix-tp5735128.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message