On Wed, Jun 27, 2018 at 12:18 AM Claus Ibsen <claus.ib...@gmail.com> wrote:
> Hi > > Its a bit confusing what you do. Are you really packaging spring-boot > inside a WAR file and then deploying that to Jetty? > If so this is wrong. Spring Boot is a standalone runtime which you > should not embed in others. > While perhaps not directly related to the users NPE problem... It is not "wrong" to package a Spring Boot-based app as a WAR and deploy to a container, though it certainly isn't the usual way. On a recent project (ended last year) using Spring Boot 1.5.4.RELEASE and Camel 2.19.1, the deployment environment dictated WARs deployed to Tomcat servers. This required changing the packaging in the POM to war, setting the spring-boot-starter-tomcat dependency to provided so as not to include conflicting tomcat classes in the WARs, and modifying the application classes as follows: @SpringBootApplication public class MyApplication extends SpringBootServletInitializer { public static void main(String[] args) { ApplicationContext applicationContext = new SpringApplication(MyApplication .class).run(args); CamelSpringBootApplicationController applicationController = applicationContext.getBean(CamelSpringBootApplicationController.class); applicationController.run(); } @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { builder.sources(MyApplication.class); return builder; } ... } The main method allows running the application from Eclipse/STS or the spring-boot maven plugin. Extending SpringBootServletInitializer and overriding configure() allows the app to initialize correctly when deployed to a container. Note that all the applications used Java config for both Spring and Camel routes. YMMV if using Spring Boot 2 > > On Sun, Jun 24, 2018 at 9:44 PM, Mohit Sharma <mohit.sha...@evry.com> > wrote: > > > > Hi All, > > > > My name is Mohit and I am working with EVRY AS Norway< > https://www.evry.com/> . > > > > I am trying to upgraded existing Spring application based web > application running on jetty to Spring boot. I have updated dependencies > (respective pom's). > > > > Now when I am running jetty, it give error for camel related > configuration, ex of camel configuration which is working on spring > > > > Context file with camel configurations : > > > > <?xml version="1.0" encoding="UTF-8"?> > > <beans xmlns="http://www.springframework.org/schema/beans" > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:util="http://www.springframework.org/schema/util" > > xmlns:context="http://www.springframework.org/schema/context" > > xmlns:camel="http://camel.apache.org/schema/spring" > > xsi:schemaLocation="http://www.springframework.org/schema/beans > http://www.springframework.org/schema/beans/spring-beans.xsd > > http://www.springframework.org/schema/util > http://www.springframework.org/schema/util/spring-util.xsd > > http://camel.apache.org/schema/spring > http://camel.apache.org/schema/spring/camel-spring.xsd > > > http://www.springframework.org/schema/context > http://www.springframework.org/schema/context/spring-context.xsd"> > > > > <bean id="notificationService" > class="com.edb.payment.pays.core.pwh.service.notification.NotificationServiceImpl"/> > > <context:component-scan > base-package="com.edb.payment.pays.core.pwh.service.notification.mapper"/> > > > > <bean id="notificationServiceDestinationResolver" > > > class="com.edb.finance.common.spring.jms.support.WmqDestinationResolver"> > > <property name="targetClient"> > > <util:constant > static-field="com.ibm.msg.client.wmq.WMQConstants.WMQ_TARGET_DEST_MQ"/> > > </property> > > <property name="encoding"> > > <util:constant > static-field="com.ibm.msg.client.wmq.WMQConstants.WMQ_ENCODING_NATIVE"/> > > </property> > > <property name="ccsid" > value="${notification.internal.mq.ccsid:1208}"/> > > <property name="baseQueueManagerName" > value="${nmq.mq.queueManager}"/> > > </bean> > > > > <camel:camelContext id="notificationServiceCamelContext" > useMDCLogging="true"> > > > > <camel:endpoint id="notificationServiceQueue" > uri="jms:queue:{{notification.internal.mq.queueName}}?connectionFactory=#NMQServiceCacheConnectionFactory&destinationResolver=#notificationServiceDestinationResolver&disableTimeToLive=true&deliveryPersistent=true&explicitQosEnabled=true&disableReplyTo=true&exchangePattern=InOnly"/> > > > > <camel:route id="cpsAdviceStatusReportServiceRoute"> > > <camel:from uri="seda:notificationRoute"/> > > <camel:convertBodyTo > type="com.evry.notification.message.v1.NotificationMessage"/> > > <camel:marshal> > > <camel:jaxb prettyPrint="true" > encoding="{{file.encoding.utf}}" > > > contextPath="com.evry.notification.message.v1"/> > > </camel:marshal> > > <camel:convertBodyTo type="java.lang.String"/> > > <camel:log logName="MESSAGE_TRACE" loggingLevel="INFO" > > message="NOTIFICATION_SERVICE: headers= > ${headers}, body= ${body}"/> > > <camel:to ref="notificationServiceQueue"/> > > </camel:route> > > > > </camel:camelContext> > > > > </beans> > > > > Error as : > > > > Error creating bean with name 'notificationService' defined in URL > [file:/D:/mohit/code/pin-server/pays-core/pays-core-pi-service/target/classes/spring/pwh-notification-service-context.xml]: > Initialization of bean failed; nested exception is > org.apache.camel.spring.GenericBeansException: Error post processing bean: > notificationService; nested exception is java.lang.NullPointerException > > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564) > > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) > > at > org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312) > > at > org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) > > at > org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308) > > at > org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) > > at > org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) > > at > org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) > > at > org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) > > at > org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) > > at > org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) > > ... 184 more > > Caused by: org.apache.camel.spring.GenericBeansException: Error post > processing bean: notificationService; nested exception is > java.lang.NullPointerException > > at > org.apache.camel.spring.CamelBeanPostProcessor.postProcessBeforeInitialization(CamelBeanPostProcessor.java:159) > > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409) > > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1626) > > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) > > ... 194 more > > Caused by: java.lang.NullPointerException > > at > org.apache.camel.impl.CamelPostProcessorHelper.matchContext(CamelPostProcessorHelper.java:85) > > at > org.apache.camel.impl.DefaultCamelBeanPostProcessor$1.doWith(DefaultCamelBeanPostProcessor.java:185) > > at > org.apache.camel.util.ReflectionHelper.doWithFields(ReflectionHelper.java:74) > > at > org.apache.camel.impl.DefaultCamelBeanPostProcessor.injectFields(DefaultCamelBeanPostProcessor.java:167) > > at > org.apache.camel.impl.DefaultCamelBeanPostProcessor.postProcessBeforeInitialization(DefaultCamelBeanPostProcessor.java:82) > > at > org.apache.camel.spring.CamelBeanPostProcessor.postProcessBeforeInitialization(CamelBeanPostProcessor.java:153) > > ... 197 more > > [INFO] Started ServerConnector@6847dfe8{HTTP/1.1,[http/1.1]}{ > 0.0.0.0:8080}<mailto:ServerConnector@6847dfe8 > %7bHTTP/1.1,%5bhttp/1.1%5d%7d%7b0.0.0.0:8080%7d> > > [INFO] Started @96732ms > > [INFO] Started Jetty Server > > > > Process finished with exit code -1 > > > > > > Can please suggest me is there any problem with spring boot and this xml > based configurations ? or do we need to take care something else as well ?? > > > > I have tried number of ways to fix this but nothing works .. so I > decided to ask you , sorry for trouble , hope I will get some suggestions > here. > > > > Also I tried to subscribe for your groups but that failed. > > > > > > Regards, > > Mohit Sharma > > > > > > > > Sensitivity: Internal > > > > -- > Claus Ibsen > ----------------- > http://davsclaus.com @davsclaus > Camel in Action 2: https://www.manning.com/ibsen2 >