title: spring is not injecting my class
body: <p>I am getting null pointer exception when I am trying to use mathUtil instance because it is not getting injected. I think becan creation is success full but not injecting?</p>
  
  <p>below is my class getting the error:</p>
  
  <pre><code>    package com.cts.mms.process.service
      @Component
      public class MocalMathVerifier implements MathVerifer {
  
          private static final Logger log = LoggerFactory.getLogger(MocalMathVerifier .class);
  
          @Autowired
          MathUtil mathUtil;
  
          @Autowired
          mathLogger mathLogger;
  
  public verifyMaths(){
         List&lt;MathObject&gt; mathObjList = mathUtil.getctList(mathList);
  
  }
  }
  </code></pre>
  
  <p>MY context.xml is as follows</p>
  
  <pre><code>&lt;beans default-autowire="no"
      xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="http://www.springframework.org/schema/beans 
                      http://www.springframework.org/schema/beans/spring-beans.xsd 
                      http://www.springframework.org/schema/context 
                      http://www.springframework.org/schema/context/spring-context-2.5.xsd"&gt;
  
      &lt;context:property-placeholder location="classpath*:mmsogenmerfier.properties" /&gt;
      &lt;context:annotation-config /&gt;
      &lt;context:component-scan base-package="com.cts.mms.process"&gt;&lt;/context:component-scan&gt;
  
      &lt;bean id="log4jInitialization"
          class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"&gt;
          &lt;property name="targetClass" value="org.springframework.util.Log4jConfigurer" /&gt;
          &lt;property name="targetMethod" value="initLogging" /&gt;
          &lt;property name="arguments"&gt;
              &lt;list&gt;
                  &lt;value&gt;classpath:log4j.properties&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"&gt;
          &lt;property name="classesToBeBound"&gt;
              &lt;array&gt;
                  &lt;value&gt;com.cts.mms.process.oxm.metagen&lt;/value&gt;
              &lt;/array&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"&gt;
          &lt;property name="host" value="localhost" /&gt;
          &lt;property name="port" value="25" /&gt;
          &lt;property name="username" value="" /&gt;
          &lt;property name="password" value="" /&gt;
          &lt;property name="javaMailProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="mail.transport.protocol"&gt;smtp&lt;/prop&gt;
                  &lt;!-- &lt;prop key="mail.smtp.auth"&gt;true&lt;/prop&gt; --&gt;
                  &lt;!-- &lt;prop key="mail.smtp.starttls.enable"&gt;true&lt;/prop&gt; &lt;prop key="mail.smtp.startssl.enable"&gt;true&lt;/prop&gt; --&gt;
                  &lt;!-- &lt;prop key="mail.debug"&gt;true&lt;/prop&gt; --&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="simpleMailMessage" class="org.springframework.mail.SimpleMailMessage"&gt;
          &lt;property name="from" value="${smtp.email.from}" /&gt;
          &lt;property name="to" value="${smtp.email.to}" /&gt;
          &lt;property name="subject" value="${smtp.email.subject}" /&gt;
          &lt;!-- &lt;property name="text" value ="${stmp.email.bodyText}"/&gt; --&gt;
  
          &lt;property name="text"&gt;
          &lt;value&gt;
          &lt;![CDATA[
              Dear %s,
              Mail Content : %s
          ]]&gt;
      &lt;/value&gt;
           &lt;/property&gt;
      &lt;/bean&gt;
  
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>Below is MathUtil class definition. removed the content from body  which think is not necessary here in the post.</p>
  
  <pre><code>package com.cts.mms.process.common;
  
  @Component("mathUtil")
  public class MathUtil { 
  
  public List&lt;MathObject&gt; getctList(List&lt;Maths&gt; mathList) {
  
  
  }
  </code></pre>
  
  <p>Below is how MocalMathVerifier is accessed</p>
  
  <pre><code>package com.cts.mms.process.service;
  @Component
  public class MathVerifierFactory {
  
  public MathVerifer getMathVerifier(Short mathtypeId){
  
      if(mathtypeId==100 )
              return new MocalMathVerifier();
  
      }
  }
  
  
  
  package com.cts.mms.process.service;
  @Component("verifier")
  public class Verifier {
  
      private static final Logger log = LoggerFactory.getLogger(Verifier.class);
      @Autowired
      private MathVerifierFactory mathVerifierFactory;
  
  public void verifyMathInfo() {
  
   mathVerifierFactory.getMathVerifier(mathId).verifyPaths(mathList);
  
  }
  </code></pre>