[jira] Created: (CAMEL-994) NullPointerException is raised by the Camel Event endpoint (org.apache.camel.component.event.EventEndpoint) during message sending (= produce)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (CAMEL-994) NullPointerException is raised by the Camel Event endpoint (org.apache.camel.component.event.EventEndpoint) during message sending (= produce)

JIRA jira@apache.org
NullPointerException is raised by the Camel Event endpoint (org.apache.camel.component.event.EventEndpoint) during message sending (= produce)
----------------------------------------------------------------------------------------------------------------------------------------------

                 Key: CAMEL-994
                 URL: https://issues.apache.org/activemq/browse/CAMEL-994
             Project: Apache Camel
          Issue Type: Bug
          Components: camel-spring
    Affects Versions: 1.4.0
            Reporter: Charles Moulliard


Hi,

I have the following error generated :

[                          main] DefaultCamelContext            INFO  JMX enabled. Using InstrumentationLifecycleStrategy.
[                          main] DefaultCamelContext            DEBUG Adding routes from: Routes: [Route[ [From[event://default]] -> [To[mock:test]]]] routes: []
[                          main] DefaultInstrumentationAgent    DEBUG Starting JMX agent on server: com.sun.jmx.mbeanserver.JmxMBeanServer@1503a3
[                          main] DefaultInstrumentationAgent    DEBUG Registered MBean with objectname: org.apache.camel:context=dell-charles/camel-1,name=context
[                          main] DefaultComponentResolver       DEBUG Found component: event via type: org.apache.camel.component.event.EventComponent via META-INF/services/org/apache/camel/component/event
[                          main] DefaultComponent               DEBUG Creating endpoint uri=[event://default], path=[default], parameters=[{}]
[                          main] DefaultCamelContext            DEBUG event://default converted to endpoint: Endpoint[event://default] by component: org.apache.camel.component.event.EventComponent@872380
[                          main] DefaultInstrumentationAgent    DEBUG Registered MBean with objectname: org.apache.camel:context=dell-charles/camel-1,type=endpoints,name="event://default\?id=0xdaebda6"
[                          main] DefaultInstrumentationAgent    DEBUG Registered MBean with objectname: org.apache.camel:context=dell-charles/camel-1,type=processors,nodeid=to1,name="To[mock:test]"
[                          main] DefaultComponentResolver       DEBUG Found component: mock via type: org.apache.camel.component.mock.MockComponent via META-INF/services/org/apache/camel/component/mock
[                          main] DefaultComponent               DEBUG Creating endpoint uri=[mock:test], path=[test], parameters=[{}]
[                          main] DefaultCamelContext            DEBUG mock:test converted to endpoint: Endpoint[mock:test] by component: org.apache.camel.component.mock.MockComponent@e0b6f5
[                          main] DefaultInstrumentationAgent    DEBUG Registered MBean with objectname: org.apache.camel:context=dell-charles/camel-1,type=endpoints,name="mock:test\?id=0x1f9866cb"
[                          main] DefaultInstrumentationAgent    DEBUG Registered MBean with objectname: org.apache.camel:context=dell-charles/camel-1,type=routes,name="node1"
[                          main] DefaultInstrumentationAgent    DEBUG Registered MBean with objectname: org.apache.camel:context=dell-charles/camel-1,type=consumers,name=EventConsumer(0x97a560)
[                          main] ProducerCache                  DEBUG >>>> Endpoint[event://default] Exchange[Message: Hello there!]
[                          main] ResolverUtil                   DEBUG Searching for annotations of org.apache.camel.Converter in packages: [org.apache.camel.converter, org.apache.camel.component.cxf.converter, org.apache.camel.spring.converter]
[                          main] ResolverUtil                   DEBUG Using only regular classloaders
[                          main] ResolverUtil                   DEBUG Loading from jar: C:\.m2\repository\org\apache\camel\camel-core\1.5-SNAPSHOT\camel-core-1.5-SNAPSHOT.jar
[                          main] ResolverUtil                   DEBUG Using only regular classloaders
[                          main] ResolverUtil                   DEBUG Loading from jar: C:\.m2\repository\org\apache\camel\camel-cxf\1.5-SNAPSHOT\camel-cxf-1.5-SNAPSHOT.jar
[                          main] ResolverUtil                   DEBUG Using only regular classloaders
[                          main] ResolverUtil                   DEBUG Found: [class org.apache.camel.converter.stream.StreamCacheConverter, class org.apache.camel.converter.CamelConverter, class org.apache.camel.converter.IOConverter, class org.apache.camel.converter.jaxp.DomConverter, class org.apache.camel.converter.jaxp.StaxConverter, class org.apache.camel.converter.jaxp.StreamSourceConverter, class org.apache.camel.converter.ObjectConverter, class org.apache.camel.converter.NIOConverter, class org.apache.camel.component.cxf.converter.CxfConverter, class org.apache.camel.converter.jaxp.XmlConverter, class org.apache.camel.converter.CollectionConverter]
[                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.converter.stream.StreamCacheConverter
[                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.converter.CamelConverter
[                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.converter.IOConverter
[                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.converter.jaxp.DomConverter
[                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.converter.jaxp.StaxConverter
[                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.converter.jaxp.StreamSourceConverter
[                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.converter.ObjectConverter
[                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.converter.NIOConverter
[                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.component.cxf.converter.CxfConverter
[                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.converter.jaxp.XmlConverter
[                          main] DefaultTypeConverter           WARN  Overriding type converter from: StaticMethodTypeConverter: public static java.lang.String org.apache.camel.converter.IOConverter.toString(javax.xml.transform.Source) throws javax.xml.transform.TransformerException,java.io.IOException to: InstanceMethodTypeConverter: public java.lang.String org.apache.camel.converter.jaxp.XmlConverter.toString(javax.xml.transform.Source) throws javax.xml.transform.TransformerException
[                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.converter.CollectionConverter
org.apache.camel.RuntimeCamelException: java.lang.NullPointerException
        at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:685)
        at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:90)
        at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:85)
        at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:102)
        at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:108)
        at com.xpectis.test.ProcessEvent.startCamel(ProcessEvent.java:44)
        at com.xpectis.test.ProcessEvent.main(ProcessEvent.java:63)
Caused by: java.lang.NullPointerException
        at org.apache.camel.component.event.EventEndpoint$1.process(EventEndpoint.java:68)
        at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:151)
        at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:88)
        ... 5 more

when I run the code above :

/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.xpectis.test;

import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class ProcessEvent {

        private static final transient Log LOG = LogFactory.getLog(ProcessEvent.class);

        protected CamelContext camelContext;

        protected Object body = "Hello there!";
        protected String uri = "event://default";
        protected ProducerTemplate<Exchange> template = null;

        public void startCamel() throws Exception {
                camelContext = new DefaultCamelContext();
               
                camelContext.addRoutes(createRouteBuilder());
                camelContext.start();

                template = camelContext.createProducerTemplate();
                template.sendBody(uri, body);
        }
       
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            @Override
                        public void configure() throws Exception {
                from("event://default").to("mock:test");
            }
        };
    }

        /**
         * @param args
         */
        public static void main(String[] args) {
               
                ProcessEvent event = new ProcessEvent();
                try {
                        event.startCamel();
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
       
}

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Resolved: (CAMEL-994) NullPointerException is raised by the Camel Event endpoint (org.apache.camel.component.event.EventEndpoint) during message sending (= produce)

JIRA jira@apache.org

     [ https://issues.apache.org/activemq/browse/CAMEL-994?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-994.
-------------------------------

    Fix Version/s: 1.5.0
       Resolution: Working as Designed

Charles you need to use spring as well as the event component is spring events.

What is needed is to set the spring application context on the endpoint before it can be used.



> NullPointerException is raised by the Camel Event endpoint (org.apache.camel.component.event.EventEndpoint) during message sending (= produce)
> ----------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-994
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-994
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-spring
>    Affects Versions: 1.4.0
>            Reporter: Charles Moulliard
>             Fix For: 1.5.0
>
>
> Hi,
> I have the following error generated :
> [                          main] DefaultCamelContext            INFO  JMX enabled. Using InstrumentationLifecycleStrategy.
> [                          main] DefaultCamelContext            DEBUG Adding routes from: Routes: [Route[ [From[event://default]] -> [To[mock:test]]]] routes: []
> [                          main] DefaultInstrumentationAgent    DEBUG Starting JMX agent on server: com.sun.jmx.mbeanserver.JmxMBeanServer@1503a3
> [                          main] DefaultInstrumentationAgent    DEBUG Registered MBean with objectname: org.apache.camel:context=dell-charles/camel-1,name=context
> [                          main] DefaultComponentResolver       DEBUG Found component: event via type: org.apache.camel.component.event.EventComponent via META-INF/services/org/apache/camel/component/event
> [                          main] DefaultComponent               DEBUG Creating endpoint uri=[event://default], path=[default], parameters=[{}]
> [                          main] DefaultCamelContext            DEBUG event://default converted to endpoint: Endpoint[event://default] by component: org.apache.camel.component.event.EventComponent@872380
> [                          main] DefaultInstrumentationAgent    DEBUG Registered MBean with objectname: org.apache.camel:context=dell-charles/camel-1,type=endpoints,name="event://default\?id=0xdaebda6"
> [                          main] DefaultInstrumentationAgent    DEBUG Registered MBean with objectname: org.apache.camel:context=dell-charles/camel-1,type=processors,nodeid=to1,name="To[mock:test]"
> [                          main] DefaultComponentResolver       DEBUG Found component: mock via type: org.apache.camel.component.mock.MockComponent via META-INF/services/org/apache/camel/component/mock
> [                          main] DefaultComponent               DEBUG Creating endpoint uri=[mock:test], path=[test], parameters=[{}]
> [                          main] DefaultCamelContext            DEBUG mock:test converted to endpoint: Endpoint[mock:test] by component: org.apache.camel.component.mock.MockComponent@e0b6f5
> [                          main] DefaultInstrumentationAgent    DEBUG Registered MBean with objectname: org.apache.camel:context=dell-charles/camel-1,type=endpoints,name="mock:test\?id=0x1f9866cb"
> [                          main] DefaultInstrumentationAgent    DEBUG Registered MBean with objectname: org.apache.camel:context=dell-charles/camel-1,type=routes,name="node1"
> [                          main] DefaultInstrumentationAgent    DEBUG Registered MBean with objectname: org.apache.camel:context=dell-charles/camel-1,type=consumers,name=EventConsumer(0x97a560)
> [                          main] ProducerCache                  DEBUG >>>> Endpoint[event://default] Exchange[Message: Hello there!]
> [                          main] ResolverUtil                   DEBUG Searching for annotations of org.apache.camel.Converter in packages: [org.apache.camel.converter, org.apache.camel.component.cxf.converter, org.apache.camel.spring.converter]
> [                          main] ResolverUtil                   DEBUG Using only regular classloaders
> [                          main] ResolverUtil                   DEBUG Loading from jar: C:\.m2\repository\org\apache\camel\camel-core\1.5-SNAPSHOT\camel-core-1.5-SNAPSHOT.jar
> [                          main] ResolverUtil                   DEBUG Using only regular classloaders
> [                          main] ResolverUtil                   DEBUG Loading from jar: C:\.m2\repository\org\apache\camel\camel-cxf\1.5-SNAPSHOT\camel-cxf-1.5-SNAPSHOT.jar
> [                          main] ResolverUtil                   DEBUG Using only regular classloaders
> [                          main] ResolverUtil                   DEBUG Found: [class org.apache.camel.converter.stream.StreamCacheConverter, class org.apache.camel.converter.CamelConverter, class org.apache.camel.converter.IOConverter, class org.apache.camel.converter.jaxp.DomConverter, class org.apache.camel.converter.jaxp.StaxConverter, class org.apache.camel.converter.jaxp.StreamSourceConverter, class org.apache.camel.converter.ObjectConverter, class org.apache.camel.converter.NIOConverter, class org.apache.camel.component.cxf.converter.CxfConverter, class org.apache.camel.converter.jaxp.XmlConverter, class org.apache.camel.converter.CollectionConverter]
> [                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.converter.stream.StreamCacheConverter
> [                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.converter.CamelConverter
> [                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.converter.IOConverter
> [                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.converter.jaxp.DomConverter
> [                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.converter.jaxp.StaxConverter
> [                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.converter.jaxp.StreamSourceConverter
> [                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.converter.ObjectConverter
> [                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.converter.NIOConverter
> [                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.component.cxf.converter.CxfConverter
> [                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.converter.jaxp.XmlConverter
> [                          main] DefaultTypeConverter           WARN  Overriding type converter from: StaticMethodTypeConverter: public static java.lang.String org.apache.camel.converter.IOConverter.toString(javax.xml.transform.Source) throws javax.xml.transform.TransformerException,java.io.IOException to: InstanceMethodTypeConverter: public java.lang.String org.apache.camel.converter.jaxp.XmlConverter.toString(javax.xml.transform.Source) throws javax.xml.transform.TransformerException
> [                          main] AnnotationTypeConverterLoader  DEBUG Loading converter class: org.apache.camel.converter.CollectionConverter
> org.apache.camel.RuntimeCamelException: java.lang.NullPointerException
>         at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:685)
>         at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:90)
>         at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:85)
>         at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:102)
>         at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:108)
>         at com.xpectis.test.ProcessEvent.startCamel(ProcessEvent.java:44)
>         at com.xpectis.test.ProcessEvent.main(ProcessEvent.java:63)
> Caused by: java.lang.NullPointerException
>         at org.apache.camel.component.event.EventEndpoint$1.process(EventEndpoint.java:68)
>         at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:151)
>         at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:88)
>         ... 5 more
> when I run the code above :
> /**
>  * Licensed to the Apache Software Foundation (ASF) under one or more
>  * contributor license agreements.  See the NOTICE file distributed with
>  * this work for additional information regarding copyright ownership.
>  * The ASF licenses this file to You under the Apache License, Version 2.0
>  * (the "License"); you may not use this file except in compliance with
>  * the License.  You may obtain a copy of the License at
>  *
>  *      http://www.apache.org/licenses/LICENSE-2.0
>  *
>  * Unless required by applicable law or agreed to in writing, software
>  * distributed under the License is distributed on an "AS IS" BASIS,
>  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>  * See the License for the specific language governing permissions and
>  * limitations under the License.
>  */
> package com.xpectis.test;
> import org.apache.camel.CamelContext;
> import org.apache.camel.Exchange;
> import org.apache.camel.ProducerTemplate;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.impl.DefaultCamelContext;
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> public class ProcessEvent {
>         private static final transient Log LOG = LogFactory.getLog(ProcessEvent.class);
>         protected CamelContext camelContext;
>         protected Object body = "Hello there!";
>         protected String uri = "event://default";
>         protected ProducerTemplate<Exchange> template = null;
>         public void startCamel() throws Exception {
>                 camelContext = new DefaultCamelContext();
>                
>                 camelContext.addRoutes(createRouteBuilder());
>                 camelContext.start();
>                 template = camelContext.createProducerTemplate();
>                 template.sendBody(uri, body);
>         }
>        
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>                         public void configure() throws Exception {
>                 from("event://default").to("mock:test");
>             }
>         };
>     }
>         /**
>          * @param args
>          */
>         public static void main(String[] args) {
>                
>                 ProcessEvent event = new ProcessEvent();
>                 try {
>                         event.startCamel();
>                 } catch (Exception e) {
>                         e.printStackTrace();
>                 }
>         }
>        
> }

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.