title: Suddenly my spring.xml won't instantiate my classes and Error Exception occurs
body: <p>I encountered a weird error that I could not understand... When I run my web project... My jsp displayed. But after clicking the submit bottom, it hangs then error results.  I could not understand what I do wrong.. it is like 3hours trying to check my problem. But right now i need some help.. Thanks guys.</p>
  
  <pre><code>Unable to instantiate Action, lotmovement.action.RegisterAction,  defined for 'register' in namespace '/'Error creating bean with name 'registeraction' defined in class path resource [spring.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [lotmovement.action.RegisterAction]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'registeraction' defined in class path resource [spring.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [lotmovement.action.RegisterAction]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'registeraction' defined in class path resource [spring.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [lotmovement.action.RegisterAction]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'registeraction' defined in class path resource [spring.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [lotmovement.action.RegisterAction]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'registeraction' defined in class path resource [spring.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: [spring.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [lotmovement.action.RegisterAction]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'registeraction' defined in class path resource [spring.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [lotmovement.action.RegisterAction]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'registeraction' defined in class path resource [spring.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [lotmovement.action.RegisterAction]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'registeraction' defined in class path resource [spring.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [lotmovement.action.RegisterAction]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [spring.xml]; nested exception is java.lang.StackOverflowError
      org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:115)
      org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61)
      org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:877)
      org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:839)
      org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
      org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
      java.security.AccessController.doPrivileged(Native Method)
      org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
      org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
      org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
      org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
      org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
      org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
      org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
      org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
      org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
      org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139)
      org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:83)
      lotmovement.action.RegisterAction.&lt;init&gt;(RegisterAction.java:27)
      sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      java.lang.reflect.Constructor.newInstance(Constructor.java:525)
      java.lang.Class.newInstance0(Class.java:372)
      java.lang.Class.newInstance(Class.java:325)
      com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:131)
      com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:162)
      com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:151)
      com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:121)
      com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:300)
      com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:400)
      com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:194)
      org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
      org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
      com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
      org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:501)
      org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:432)
  </code></pre>
  
  <p>And on the tomcat server, this keeps on repeating..</p>
  
  <pre><code>Nov 26, 2012 3:10:51 PM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
  INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@2d43b35f: defining beans [userprofile,registeraction,insertuserprofile,entitystart,recordexistuserprofile]; root of factory hierarchy
  Nov 26, 2012 3:10:51 PM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
  INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@50016db: defining beans [userprofile,registeraction,insertuserprofile,entitystart,recordexistuserprofile]; root of factory hierarchy
  Nov 26, 2012 3:10:51 PM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
  INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@7ef1277f: defining beans [userprofile,registeraction,insertuserprofile,entitystart,recordexistuserprofile]; root of factory hierarchy
  Nov 26, 2012 3:10:51 PM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
  INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@3d510eb6: defining beans [userprofile,registeraction,insertuserprofile,entitystart,recordexistuserprofile]; root of factory hierarchy
  Nov 26, 2012 3:10:51 PM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
  INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@66893099: defining beans [userprofile,registeraction,insertuserprofile,entitystart,recordexistuserprofile]; root of factory hierarchy
  Nov 26, 2012 3:17:59 PM org.apache.catalina.startup.HostConfig checkResources
  INFO: Undeploying context [/LotMovement_5spingtest]
  </code></pre>
  
  <p>This is my XML file.</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"
         xsi:schemaLocation="
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"&gt;
  
      &lt;bean id="userprofile"  class="lotmovement.business.entity.UserProfile"&gt;
  
      &lt;/bean&gt;
  
      &lt;bean id="registeraction"  class="lotmovement.action.RegisterAction"&gt;
  
      &lt;/bean&gt;  
  
      &lt;bean id="insertuserprofile"  
            class="lotmovement.business.crud.InsertUserProfile"&gt;
  
      &lt;/bean&gt;
  
  
      &lt;bean id="entitystart"  
            class="lotmovement.business.crud.EntityStart"&gt;
  
      &lt;/bean&gt;
  
      &lt;bean id="recordexistuserprofile"  
             class="lotmovement.business.crud.RecordExistUserProfile"&gt;
  
      &lt;/bean&gt;
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>This is my some of my code..</p>
  
  <pre><code>/*
   * To change this template, choose Tools | Templates
   * and open the template in the editor.
   */
  package lotmovement.action;
  
  import com.opensymphony.xwork2.ActionSupport;
  import lotmovement.business.crud.EntityStart;
  import lotmovement.business.crud.InsertUserProfile;
  import lotmovement.business.crud.RecordExistUserProfile;
  import lotmovement.business.entity.UserProfile;
  import org.apache.commons.lang3.StringUtils;
  import org.springframework.context.ApplicationContext;
  import org.springframework.context.support.ClassPathXmlApplicationContext;
  
  /**
   *
   * @author god-gavedmework
   */
  public class RegisterAction extends ActionSupport {
  
      private static String userId;
      private static String password;
      private static String firstName;
      private static String lastName;
      private static int securityLevel;
      ApplicationContext context =
              new ClassPathXmlApplicationContext("spring.xml");
      EntityStart es = (EntityStart) context.getBean("entitystart");
  
      @Override
      public void validate() {
          es.StartDbaseConnection();
          RecordExistUserProfile reup =
                  (RecordExistUserProfile) context.getBean("recordexistuserprofile");
          if (reup.checkrecordexist()) {
              addActionError("record already exist.");
          }
      }
  
      @Override
      public String execute() {
  
  
  
          InsertUserProfile iup =
                  (InsertUserProfile) context.getBean("insertuserprofile");
  
  
  
          iup.Insert();
  
  
          return SUCCESS;
      }
  </code></pre>
  
  <p>This is my WEB.XML</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
      &lt;filter&gt;
          &lt;filter-name&gt;struts2&lt;/filter-name&gt;
          &lt;filter-class&gt;org.apache.struts2.dispatcher.FilterDispatcher&lt;/filter-class&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;struts2&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
      &lt;session-config&gt;
          &lt;session-timeout&gt;
              30
          &lt;/session-timeout&gt;
      &lt;/session-config&gt;
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;register.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>