I don't know enough about the inner workings of Camel to tell you about the
version issue.
If i remember rightly, I've heard of or experience the same sort of thing
when doing outside the box things, like this. It is really a timing issue,
if i remember rightly.



On Tue, Oct 24, 2017 at 1:18 PM, Dicken George <dickengeo...@gmail.com>
wrote:

> so in the stack trace it talks about line 66 but when i debug i can see
> that
>
>            "camelContext.startRoute("salesforce-versions");            "
>
> already in line 64 meaning the route is not started as the routeservices
> object is empty (null).  Which thereby causes and expection at line 66
> which is
>
>            Endpoint ep = theRoute.getEndpoint();
>
> I am wondering if there any specific call which adds all routes to the
> camelcontext differently in 2.19.x compared to 2.20.0 ?
>
>
>
> On Tue, Oct 24, 2017 at 7:13 PM, Mark Nuttall <mknutt...@gmail.com> wrote:
>
> > Oh. i missed the "complex use case". Of the code you provided, what is
> line
> > 66?
> >
> > On Tue, Oct 24, 2017 at 11:47 AM, Mark Nuttall <mknutt...@gmail.com>
> > wrote:
> >
> > > Is there any reason you are not using the standard Spring Boot + Camel
> > > mechanisms to create the context and routes. I don't readily see any in
> > > your code.  Doing so might resolve the problem.  Let me know if you
> need
> > > help with that..
> > >
> > > Mark
> > >
> > > On Tue, Oct 24, 2017 at 9:36 AM, Dicken George <dickengeo...@gmail.com
> >
> > > wrote:
> > >
> > >> Dear Fellow Developers,
> > >>
> > >> Just recently, I tried to upgrade my camel-spring boot project form
> > camel
> > >> 2.19.3 to camel 2.20.0 and I face the problem that, I cannot boot up
> my
> > >> application any more, and I get the following stack trace
> > >>
> > >> java.lang.NullPointerException
> > >> at
> > >> com.haufe.ssmp.sfdc.api.app.BeanConfiguration.afterApplicati
> > >> onStart(BeanConfiguration.java:66)
> > >> at
> > >> org.apache.camel.spring.boot.RoutesCollector.onApplicationEv
> > >> ent(RoutesCollector.java:226)
> > >> at
> > >> org.apache.camel.spring.boot.RoutesCollector.onApplicationEv
> > >> ent(RoutesCollector.java:54)
> > >> at
> > >> org.springframework.context.event.SimpleApplicationEventMult
> > >> icaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
> > >> at
> > >> org.springframework.context.event.SimpleApplicationEventMult
> > >> icaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
> > >> at
> > >> org.springframework.context.event.SimpleApplicationEventMult
> > >> icaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
> > >> at
> > >> org.springframework.context.support.AbstractApplicationConte
> > >> xt.publishEvent(AbstractApplicationContext.java:393)
> > >> at
> > >> org.springframework.context.support.AbstractApplicationConte
> > >> xt.publishEvent(AbstractApplicationContext.java:347)
> > >> at
> > >> org.springframework.context.support.AbstractApplicationConte
> > >> xt.finishRefresh(AbstractApplicationContext.java:883)
> > >> at
> > >> org.springframework.boot.context.embedded.EmbeddedWebApplica
> > >> tionContext.finishRefresh(EmbeddedWebApplicationContext.java:144)
> > >> at
> > >> org.springframework.context.support.AbstractApplicationConte
> > >> xt.refresh(AbstractApplicationContext.java:546)
> > >> at
> > >> org.springframework.boot.context.embedded.EmbeddedWebApplica
> > >> tionContext.refresh(EmbeddedWebApplicationContext.java:122)
> > >> at
> > >> org.springframework.boot.SpringApplication.refresh(SpringApp
> > >> lication.java:693)
> > >> at
> > >> org.springframework.boot.SpringApplication.refreshContext(Sp
> > >> ringApplication.java:360)
> > >> at
> > >> org.springframework.boot.SpringApplication.run(SpringApplica
> > >> tion.java:303)
> > >> at
> > >> org.springframework.boot.SpringApplication.run(SpringApplica
> > >> tion.java:1118)
> > >> at
> > >> org.springframework.boot.SpringApplication.run(SpringApplica
> > >> tion.java:1107)
> > >> at com.haufe.ssmp.sfdc.api.Application.main(Application.java:12)
> > >>
> > >> Due to my complex use case, i would like to start one specific route
> > >> manually and not use the autoconfiguration and autostart from
> > >> camelcontext.
> > >> I do this in my configuration class by over riding the before
> > application
> > >> start and after application start methods.
> > >>
> > >> @Configuration
> > >> class BeanConfiguration implements CamelContextConfiguration {
> > >>     private static final Logger log =
> > >> LoggerFactory.getLogger(BeanConfiguration.class);
> > >>
> > >>     @Override
> > >>     public void beforeApplicationStart(CamelContext camelContext) {
> > >>         camelContext.setPackageScanClassResolver(new
> > >> FatJarPackageScanClassResolver());
> > >>         camelContext.resolveDataFormat("json-jackson");
> > >>     }
> > >>
> > >>     @Autowired
> > >>     SalesforceComponent sfdcComp;
> > >>
> > >>     @Override
> > >>     public void afterApplicationStart(CamelContext camelContext) {
> > >>
> > >>         try {
> > >>             sfdcComp.start();
> > >>             camelContext.startRoute("salesforce-versions");
> > >>             Route theRoute = camelContext.getRoute("salesfo
> > >> rce-versions");
> > >>             Endpoint ep = theRoute.getEndpoint();
> > >>
> > >>             Exchange exchange = ep.createExchange();
> > >>             ProducerTemplate template =
> > >> exchange.getContext().createProducerTemplate();
> > >>             DefaultExchange o = (DefaultExchange) template.request(ep,
> > new
> > >> Processor() {
> > >>
> > >>                 @Override
> > >>                 public void process(Exchange exchange) throws
> Exception
> > {
> > >>                     // TODO Auto-generated method stub
> > >>
> > >>                 }
> > >>             });
> > >>             Object result = o.getOut().getBody();
> > >>             if(result == null && !(result instanceof ArrayList))
> > >>                     throw new Exception("No Salesforce version, login
> > >> failed.");
> > >>
> > >>             ArrayList theList = (ArrayList) result;
> > >>             if(theList.size() <= 1)
> > >>                     throw new Exception("No Salesforce version got,
> > login
> > >> failed.");
> > >>             log.debug("Connection to salesforce successfully
> > >> established:");
> > >>
> > >>         } catch (Exception e) {
> > >>             // TODO Auto-generated catch block
> > >>             e.printStackTrace();
> > >>             throw new RuntimeException("No Connection to salesforce");
> > >>         }
> > >>
> > >>     }
> > >> In this code, i saw during my debugging that it was able to start the
> > >> routes in camelcontext object and get the endpoints, however with
> > version
> > >> 2.20.0 I see my routes are not added to the camelcontext and no routes
> > are
> > >> started.
> > >>
> > >> Could anyone help me here to trouble shoot this issue ?
> > >>
> > >> Thanks in advance
> > >> --
> > >>
> > >> Dicken George
> > >>
> > >
> > >
> >
>
>
>
> --
>
> Dicken George
>

Reply via email to