title: Error creating bean with name 'resolver' defined in WebMVCConfig resource [/com.chat.config/]
body: <p>I had problems with context initialization. I don't use xml-configuration files. I read many articles about similar problems but.. I've wanted to make spring configuration with no xml, but error appears. Please help to solve.</p>
  
  <pre><code>`org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'resolver' defined in com.chat.config.WebMVCConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.view.InternalResourceViewResolver]: Factory method 'resolver' threw exception; nested exception is java.lang.StackOverflowError
      at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
  </code></pre>
  
  <p>Here is my WebMVCConfig</p>
  
  <pre><code>  @Configuration
      @ComponentScan("com.chat")
      @EnableWebMvc
      public class WebMVCConfig extends WebMvcConfigurerAdapter {
  
      @Override
      public void addResourceHandlers(ResourceHandlerRegistry registry) {
          registry.addResourceHandler("/scripts/**").addResourceLocations("/scripts/");
          registry.addResourceHandler("/styles/**").addResourceLocations("/styles/");
          registry.addResourceHandler("/images/**").addResourceLocations("/images/");
          registry.addResourceHandler("/fonts/**").addResourceLocations("/fonts/");
          registry.addResourceHandler("/pages/**").addResourceLocations("/views/");
  
      }
  
      @Override
      public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
          configurer.enable();
  
      }
      @Bean
      public InternalResourceViewResolver resolver() {
          InternalResourceViewResolver resolver = new InternalResourceViewResolver();
  
          resolver().setPrefix("/views/");
          resolver().setSuffix(".jsp");
          resolver.setViewClass(JstlView.class);
          return resolver;
      }
  }
  </code></pre>
  
  <p>WebInit</p>
  
  <pre><code>    public class WebInit extends 
      AbstractAnnotationConfigDispatcherServletInitializer {
      // Этот метод должен содержать конфигурации которые инициализируют Beans
      // для инициализации бинов у нас использовалась аннотация @Bean
      @Override
      protected Class&lt;?&gt;[] getRootConfigClasses() {
          return new Class&lt;?&gt;[]{
                  WebMVCConfig.class
          };
      }
  
      // Тут добавляем конфигурацию, в которой инициализируем ViewResolver
      @Override
      protected Class&lt;?&gt;[] getServletConfigClasses() {
  
          return new Class&lt;?&gt;[]{
                  WebMVCConfig.class
          };
      }
  
      @Override
      protected String[] getServletMappings() {
          return new String[]{"/","/login", "/chat","/dialog","/registration" };
      }
  
  }
  </code></pre>
  
  <p>pom.xml</p>
  
  <pre><code>   &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0   
  
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;MyChat&lt;/groupId&gt;
      &lt;artifactId&gt;MyChat&lt;/artifactId&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
  &lt;dependencies&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
          &lt;version&gt;4.3.8.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax&lt;/groupId&gt;
          &lt;artifactId&gt;javaee-web-api&lt;/artifactId&gt;
          &lt;version&gt;7.0&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;jstl&lt;/groupId&gt;
          &lt;artifactId&gt;jstl&lt;/artifactId&gt;
          &lt;version&gt;1.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.websocket&lt;/groupId&gt;
          &lt;artifactId&gt;javax.websocket-api&lt;/artifactId&gt;
          &lt;version&gt;1.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;taglibs&lt;/groupId&gt;
          &lt;artifactId&gt;standard&lt;/artifactId&gt;
          &lt;version&gt;1.1.2&lt;/version&gt;
      &lt;/dependency&gt;
  
  &lt;/dependencies&gt;
  
  &lt;/project&gt;
  </code></pre>