title: SEVERE: Context initialization failed and org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException
body: <p>I new for spring mvc and jdo and I try to learn I got error of </p>
  
  <p>HTTP ERROR 503</p>
  
  <p>Problem accessing /add. Reason:</p>
  
  <pre><code>org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 11 in XML document from ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 11; columnNumber: 28; The prefix "mvc" for element "mvc:annotation-driven" is not bound.
  </code></pre>
  
  <p>my program of spring mvc is placed here:</p>
  
  <p>person.java:</p>
  
  <pre><code>package com.web.project;
  
  import java.util.Date;
  
  import javax.jdo.annotations.IdGeneratorStrategy;
  import javax.jdo.annotations.PersistenceCapable;
  import javax.jdo.annotations.Persistent;
  import javax.jdo.annotations.PrimaryKey;
  
  import com.google.appengine.api.datastore.Key;
  
  
  
  
  @PersistenceCapable
  public class Person {
  
          // ID or key unique variable 
          @PrimaryKey
          @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
          private Key key;
  
          // String or integer or other variable related to person
          @Persistent
          private String name ;
  
          @Persistent
          private String email;
  
          @Persistent
          private Date date;
  
          //getter and setter methods
  
          public void setKey(Key key) {
              this.key = key;
          }
  
          public void setName(String name) {
              this.name = name;
          }
  
          public void setEmail(String email) {
              this.email = email;
          }
  
          public void setDate(Date date) {
              this.date = date;
          }
  
          public Key getKey() {
              return key;
          }
  
          public String getName() {
              return name;
          }
  
          public String getEmail() {
              return email;
          }
  
          public Date getDate() {
              return date;
          }
  
          @Override
          public String toString() {
              return "Person [key=" + key + ", name=" + name + ", email=" + email
                      + ", date=" + date + "]";
          }    
  }
  </code></pre>
  
  <p>personalcontroller.java:</p>
  
  <pre><code>package com.web.project;
  
  import java.util.Date;
  import java.util.List;
  
  import javax.jdo.PersistenceManager;
  import javax.jdo.Query;
  import javax.servlet.http.HttpServletRequest;
  
  import com.web.project.Person;
  
  import org.springframework.ui.ModelMap;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.PathVariable;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.servlet.ModelAndView;
  
  
  @Controller
  public class Personalcontroller {
      PersistenceManager pm = PMF.get().getPersistenceManager();
      List&lt;Person&gt; results = null;
  
      @RequestMapping(value="/add")
      public ModelAndView add(HttpServletRequest request, ModelMap model)
      {
          System.out.println("inside the add service");
          String name = request.getParameter("name");
          String email = request.getParameter("email");
  
  
          try
          {
              Person p = new Person();
              p.setName(name);
              p.setEmail(email);
              p.setDate(new Date());
  
              pm.makePersistent(p);
          }
  
          finally
          {
              pm.close();
          }
  
          return new ModelAndView("redirect:link");
      }
  
      @RequestMapping(value="/update")
      public ModelAndView update(HttpServletRequest request, ModelMap model)
      {
          String name = request.getParameter("name");
          String email = request.getParameter("email");
          String key = request.getParameter("key");
          try 
          {
          Person p = pm.getObjectById(Person.class, key);
          p.setName(name);
          p.setEmail(email);
          p.setDate(new Date());          
          } 
          catch (Exception e)
          {
          pm.close();
          }
          return new ModelAndView("redirect:link");
      }
  
      @RequestMapping(value = "/delete/{key}")
      public ModelAndView delete(@PathVariable String key, HttpServletRequest request, ModelMap model) {
          try {
  
              Person p = pm.getObjectById(Person.class, key);
              pm.deletePersistent(p);
  
          } finally {
  
              pm.close();
          }
          return new ModelAndView("redirect:list");
      }
      @SuppressWarnings("unchecked")
      @RequestMapping(value = "/list", method = RequestMethod.GET)
      public String listPerson(ModelMap model) {
  
          Query q = pm.newQuery(Person.class);
          q.setOrdering("date desc");
  
          try {
              results = (List&lt;Person&gt;) q.execute();
  
              if (results.isEmpty()) {
                  model.addAttribute("list", null);
              } else {
                  model.addAttribute("list", results);
              }
  
          } finally {
              q.closeAll();
              pm.close();
          }
  
          return "list";
  
      }
  }
  </code></pre>
  
  <p>PMF.java:</p>
  
  <pre><code>package com.web.project;
  
  import javax.jdo.*;
  
  public final class PMF {
      private static final PersistenceManagerFactory pmfInstance = JDOHelper.getPersistenceManagerFactory("transactions-optional");
      private PMF(){
  
      }
      public static PersistenceManagerFactory get()
      {
          return pmfInstance;
      }
  
  }
  </code></pre>
  
  <p>personal.jsp:</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ page import="com.google.appengine.api.datastore.KeyFactory, java.util.Date, java.util.List;" %&gt;
  &lt;%@ page import="com.web.project.Person" %&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
      &lt;h1&gt;GAE + Spring 3 MVC REST + CRUD Example with JDO&lt;/h1&gt;
  
      Function : &lt;a href="add.jsp"&gt;Add Person&lt;/a&gt;
      &lt;hr /&gt;
  
      &lt;h2&gt;All Person&lt;/h2&gt;
      &lt;table border="1"&gt;
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;td&gt;Name&lt;/td&gt;
                  &lt;td&gt;Email&lt;/td&gt;
                  &lt;td&gt;Created Date&lt;/td&gt;
                  &lt;td&gt;Action&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
  
          &lt;%
  
          if(request.getAttribute("list")!=null){
  
              List&lt;Person&gt; person = (List&lt;Person&gt;) request.getAttribute("list");
  
              if(!person.isEmpty()){
                   for(Person p : person){
  
          %&gt;
                  &lt;tr&gt;
                    &lt;td&gt;&lt;%=p.getName() %&gt;&lt;/td&gt;
                    &lt;td&gt;&lt;%=p.getEmail() %&gt;&lt;/td&gt;
                    &lt;td&gt;&lt;%=p.getDate() %&gt;&lt;/td&gt;
                &lt;td&gt;&lt;a href="update/&lt;%=p.getName()%&gt;"&gt;Update&lt;/a&gt; | 
                                        &lt;a href="delete/&lt;%=KeyFactory.keyToString(p.getKey()) %&gt;"&gt;
                                         Delete&lt;/a&gt;
                                    &lt;/td&gt;
                  &lt;/tr&gt;
          &lt;%  
  
                  }
  
              }
  
             }
          %&gt; 
      &lt;/table&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>add.jsp:</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
      &lt;h1&gt;Add Person&lt;/h1&gt;
  
      &lt;form method="GET" action="/add"&gt;
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td&gt;UserName :&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" style="width: 185px;" maxlength="30"
                      name="name" id="name" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Email :&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" style="width: 185px;" maxlength="30"
                      name="email" id="email" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
          &lt;input type="submit" class="save" title="Save" value="Save" /&gt;
      &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>update.jsp:</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;%@ page import="com.web.project.Person" %&gt;
  &lt;%@ page import="com.google.appengine.api.datastore.KeyFactory" %&gt;
  &lt;html&gt;
  &lt;body&gt;
      &lt;h1&gt;Update Customer&lt;/h1&gt;
  
      &lt;%
          Person person = new Person();
  
          if(request.getAttribute("person")!=null){
  
              person = (Person)request.getAttribute("person");
  
          }
  
      %&gt;
  
      &lt;form method="post" action="../update" &gt;
          &lt;input type="hidden" name="key" id="key" 
              value="&lt;%=KeyFactory.keyToString(person.getKey()) %&gt;" /&gt; 
  
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      UserName :
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;input type="text" style="width: 185px;" 
                                               maxlength="30" name="name" id="name" 
                          value="&lt;%=person.getName() %&gt;" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Email :
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;input type="text" style="width: 185px;" 
                                               maxlength="30" name="email" id="email" 
                          value="&lt;%=person.getEmail() %&gt;" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
          &lt;input type="submit" class="update" title="Update" value="Update" /&gt;
      &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>During excution 
  Error:</p>
  
  <pre><code>SEVERE: Context initialization failed
  
  org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 11 in XML document from ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 11; columnNumber: 29; The prefix "mvc" for element "mvc:annotation-driven" is not bound.
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
      at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
      at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:540)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:454)
      at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:643)
      at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:606)
      at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:657)
      at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:525)
      at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:466)
      at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
      at javax.servlet.GenericServlet.init(GenericServlet.java:212)
      at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:440)
      at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:263)
      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
      at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:685)
      at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
      at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
      at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
      at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
      at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
      at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
      at org.mortbay.jetty.Server.doStart(Server.java:224)
      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
      at com.google.appengine.tools.development.JettyContainerService.startContainer(JettyContainerService.java:255)
      at com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:288)
      at com.google.appengine.tools.development.AutomaticInstanceHolder.startUp(AutomaticInstanceHolder.java:26)
      at com.google.appengine.tools.development.AbstractModule.startup(AbstractModule.java:87)
      at com.google.appengine.tools.development.Modules.startup(Modules.java:105)
      at com.google.appengine.tools.development.DevAppServerImpl.doStart(DevAppServerImpl.java:258)
      at com.google.appengine.tools.development.DevAppServerImpl.access$000(DevAppServerImpl.java:47)
      at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:213)
      at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:211)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:211)
      at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:277)
      at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:48)
      at com.google.appengine.tools.development.DevAppServerMain.run(DevAppServerMain.java:219)
      at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:210)
  Caused by: org.xml.sax.SAXParseException; lineNumber: 11; columnNumber: 29; The prefix "mvc" for element "mvc:annotation-driven" is not bound.
      at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
      at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)
      at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:289)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2786)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
      at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
      at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
      at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243)
      at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:347)
      at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadDocument(XmlBeanDefinitionReader.java:428)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
      ... 46 more
  </code></pre>