title: Null Pointer Exception Spring Integration messaging
body: <p>i"m getting started with Spring integration ....The following code produced a null pointer exception.</p>
  
  <p>Spring context.xml(Spring configuration)</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:int="http://www.springframework.org/schema/integration"
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/integration
      http://www.springframework.org/schema/integration/spring-integration-2.1.xsd
      http://www.springframework.org/schema/context 
      http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;
      &lt;context:component-scan base-package="co.in" /&gt;
  
      &lt;int:channel id="input" /&gt;
      &lt;int:channel id="output"&gt;
          &lt;int:queue capacity="10" /&gt;
      &lt;/int:channel&gt;
      &lt;int:service-activator input-channel="input"
          output-channel="output" ref="messageHandler" /&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>app.java(The main class)</p>
  
  <pre><code>package co.in;
  
  import org.springframework.context.support.ClassPathXmlApplicationContext;
  import org.springframework.integration.Message;
  import org.springframework.integration.MessageChannel;
  import org.springframework.integration.core.PollableChannel;
  import org.springframework.integration.support.MessageBuilder;
  
  public class app {
      public static void main(String[] args) {
          ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
                  "classpath:resources/spring-context.xml");
          context.start();
  
          MessageChannel input = (MessageChannel) context.getBean("input",
                  MessageChannel.class);
          PollableChannel output = (PollableChannel) context.getBean("output",
                  PollableChannel.class);
          input.send(MessageBuilder.withPayload("Pro Spring Integration Example")
                  .build());
  
          Message&lt;?&gt; reply = output.receive();
          System.out.println("received: " + reply);
  
      }
  }
  </code></pre>
  
  <p>MessageHandler.java (Service activator bean defnition)</p>
  
  <pre><code>package co.in;
  
  import org.springframework.integration.annotation.ServiceActivator;
  
  @Component
  public class MessageHandler {
  
      @ServiceActivator
      public String handleMessage(String message) {
          System.out.println("Received message: " + message);
          return "MESSAGE:" + message;
      }
  } 
  </code></pre>
  
  <p>Error stack</p>
  
  <pre><code>Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [resources/spring-context.xml]; nested exception is java.lang.NullPointerException
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
      at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:113)
      at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:80)
      at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
      at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:83)
      at co.in.app.main(app.java:11)
  Caused by: java.lang.NullPointerException
      at org.springframework.beans.factory.support.BeanDefinitionReaderUtils.generateBeanName(BeanDefinitionReaderUtils.java:115)
      at org.springframework.beans.factory.support.BeanDefinitionReaderUtils.generateBeanName(BeanDefinitionReaderUtils.java:159)
      at org.springframework.beans.factory.support.DefaultBeanNameGenerator.generateBeanName(DefaultBeanNameGenerator.java:31)
      at org.springframework.beans.factory.xml.XmlReaderContext.generateBeanName(XmlReaderContext.java:77)
      at org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.resolveId(AbstractBeanDefinitionParser.java:102)
      at org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:59)
      at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69)
      at org.springframework.integration.config.xml.AbstractIntegrationNamespaceHandler.parse(AbstractIntegrationNamespaceHandler.java:57)
      at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1297)
      at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1287)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398)
      ... 14 more
  </code></pre>