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.afterApplicationStart(BeanConfiguration.java:66)
at
org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:226)
at
org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:54)
at
org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at
org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
at
org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883)
at
org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
at
org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at
org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at
org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at
org.springframework.boot.SpringApplication.run(SpringApplication.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("salesforce-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