title: HTTP Status 500 - Request processing failed; nested exception is java.lang.NullPointerException
body: <p>I am having difficulties while trying to launch my application, I looked for my mistake for a couple of days but i am stuck somewhere in the code and asking for your assistance... Thanks</p>
  
  <p>Add Customer COntrller :</p>
  
  <pre><code> package com.witlab.controller;
  
  import com.witlab.services.CustomerService;
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.ModelMap;
  import org.springframework.web.bind.annotation.ModelAttribute;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import com.witlab.services.CustomerService;
  import com.witlab.customer.Customer;
  import org.springframework.beans.factory.annotation.Autowired;
  
  @Controller
  public class AddCustomerController {
  
   @Autowired
  CustomerService customerservice;
  
  @RequestMapping(value="/AddCustomer", method = RequestMethod.GET)
  public String addcustomer(@ModelAttribute Customer customer) {
      return "AddCustomer";
      }
  
      @RequestMapping(value ="InsertCustomer", method = RequestMethod.POST)
      public String insertCustomer(@ModelAttribute ("customer") Customer customer, ModelMap model)
      {                 System.out.println(customer.getAddress());
          if (customer!=null)
          {
              System.out.println(customer.getName());
              System.out.println(customer.getCity());
              System.out.println(customer.getPhone());
            System.out.println(model.addAttribute("Name", customer.getName()));
  
  
         model.addAttribute("Name", customer.getName());
          model.addAttribute("Address", customer.getAddress());
          model.addAttribute("city", customer.getCity());
          model.addAttribute("phone", customer.getPhone());
          model.addAttribute("mobile", customer.getMobile());
              customerservice.createCustomer(customer);
          }
          else
          {
              System.out.print("Error");
          }
          return "AddCustomer";
      }
  
  
  
  }
  </code></pre>
  
  <p>dispatcher-servlet :</p>
  
  <pre><code>&lt;context:annotation-config /&gt; 
  
  &lt;context:component-scan base-package="com.witlab.controller" /&gt;
  
  
  &lt;bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver"
        p:prefix="/WEB-INF/jsp/"
        p:suffix=".jsp" /&gt;
  
  
  
        &lt;bean id="CustomerDAO" class="com.witlab.customer.CustomerJDBCTemplate" /&gt;  
        &lt;bean id="customerService" class="com.witlab.services.CustomerServiceImpl" /&gt;  
  &lt;bean id="propertyConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
        p:location="/WEB-INF/jdbc.properties" /&gt; 
  
  &lt;bean id="dataSource"
  class="org.springframework.jdbc.datasource.DriverManagerDataSource"
  p:driverClassName="${jdbc.driverClassName}"
  p:url="${jdbc.url}"
  p:username="${jdbc.username}"
  p:password="${jdbc.password}" /&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>Customer Service :</p>
  
  <pre><code>package com.witlab.services;
  
  import com.witlab.customer.Customer;
  import java.util.List;
  
  public interface CustomerService {
  public void createCustomer(Customer customer);
  public Customer getCustomer(double Id);
  public List&lt;Customer&gt; getCustomers();
  public void deleteCustomer(double Id);
  public void updateCustomer(double Id, String Name, String Address, String city, String phone, String mobile);
  
  }
  </code></pre>
  
  <p>Customer JDBCTemplate :</p>
  
  <pre><code>package com.witlab.customer;
  
  import java.util.List; 
  import javax.sql.DataSource; 
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.instrument.classloading.jboss.JBossLoadTimeWeaver;
  import org.springframework.jdbc.core.JdbcTemplate;
  
  public class CustomerJDBCTemplate implements CustomerDAO{
  
  @Autowired
  DataSource dataSource;
  
  
  private JdbcTemplate jdbcTemplateobj;
  
  public void setDataSource(DataSource dataSource)
  {
      this.dataSource = dataSource; 
      this.jdbcTemplateobj = new JdbcTemplate(dataSource);
  } 
  
  
   public void createCustomer(Customer customer) {
       System.out.print("In Template"+customer.getName());
      String SQL="insert into customer (Name, Address,city, phone, mobile) values (?, ?, ?, ?, ?)";
      jdbcTemplateobj.update(SQL, new Object[]{customer.getName(),     customer.getAddress(),customer.getCity(), customer.getPhone(), customer.getMobile()});
      return;        
  }
  
  @Override
  public Customer getCustomer(double Id) {
      String SQL="select * from customer where Id=?";
      Customer customer=jdbcTemplateobj.queryForObject(SQL, new Object[]{Id},new CustomerMapper());
      return customer;
  }
  
  
  public List&lt;Customer&gt; getCustomers() {
      String SQL="select * from customer";
      List &lt;Customer&gt; customers=jdbcTemplateobj.query(SQL, new CustomerMapper());
      return  customers;
  }
  
  @Override
  public void deleteCustomer(double Id) {
      String SQL="delete from customer where Id=?";
      jdbcTemplateobj.update(SQL, Id);
      return;
  }
  
  
  @Override
  public void updateCustomer(double Id, String Name, String Address, String city, String phone, String mobile) {
      String SQL = "update customer set String = ?, String = ?, String = ?, String = ?, mobile = ? where Id = ?";
      jdbcTemplateobj.update(SQL, Name, Address, city, phone, mobile, Id);
      return;
  }   
  
  }
  </code></pre>
  
  <p>Error :</p>
  
  <pre><code>Feb 05, 2014 12:49:55 AM org.apache.catalina.core.ApplicationContext log
  INFO: Destroying Spring FrameworkServlet 'dispatcher'
  Feb 05, 2014 12:49:55 AM org.apache.catalina.core.ApplicationContext log
  INFO: Closing Spring root WebApplicationContext
  Feb 05, 2014 12:50:36 AM org.apache.catalina.core.ApplicationContext log
  INFO: No Spring WebApplicationInitializer types detected on classpath
  Feb 05, 2014 12:50:36 AM org.apache.catalina.core.ApplicationContext log
  INFO: Initializing Spring root WebApplicationContext
  Feb 05, 2014 12:50:37 AM org.apache.catalina.core.ApplicationContext log
  INFO: Initializing Spring FrameworkServlet 'dispatcher'
  Feb 05, 2014 12:50:55 AM org.apache.catalina.core.StandardWrapperValve invoke
  SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/WhizzyBilling] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
  java.lang.NullPointerException
      at com.witlab.customer.CustomerJDBCTemplate.createCustomer(CustomerJDBCTemplate.java:37)
      at com.witlab.services.CustomerServiceImpl.createCustomer(CustomerServiceImpl.java:26)
      at com.witlab.controller.AddCustomerController.insertCustomer(AddCustomerController.java:49)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
      at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:440)
      at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:428)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
      at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
      at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
      at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
      at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
      at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:722)
  </code></pre>