title: Swagger 2 integration with Spring boot application
body: <p>Getting error while integrating Swagger2 with spring boot application. I am stuck with this implementation. Any problem with the implementation or configuration?</p>
  
  <p>Below are the configurations I have done to integrate Swagger2.</p>
  
  <p><strong>SwaggerConfig.java</strong></p>
  
  <pre><code>import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  
  import springfox.documentation.builders.PathSelectors;
  import springfox.documentation.builders.RequestHandlerSelectors;
  import springfox.documentation.service.ApiInfo;
  import springfox.documentation.spi.DocumentationType;
  import springfox.documentation.spring.web.plugins.Docket;
  import springfox.documentation.swagger2.annotations.EnableSwagger2;
  
  @Configuration
  @EnableSwagger2
  public class SwaggerConfig {
      @Bean
      public Docket api(){
          return new Docket(DocumentationType.SWAGGER_2)
              .select()
              .apis(RequestHandlerSelectors.any())
              .paths(PathSelectors.regex("/api/.*"))
              .build()
              .apiInfo(apiInfo());
      }
  
      @SuppressWarnings("deprecation")
      private ApiInfo apiInfo() {
          ApiInfo apiInfo = new ApiInfo(
              "My Project's REST API",
              "This is a description of your API.",
              "API TOS",
              "me@wherever.com",
              "API License",
              "API License URL", null
          );
          return apiInfo;
      }
  }
  </code></pre>
  
  <p><strong>pom.xml</strong></p>
  
  <p>Added required dependencies of swagger2</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;io.springfox&lt;/groupId&gt;
      &lt;artifactId&gt;springfox-swagger2&lt;/artifactId&gt;
      &lt;version&gt;2.5.0&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;io.springfox&lt;/groupId&gt;
      &lt;artifactId&gt;springfox-swagger-ui&lt;/artifactId&gt;
      &lt;version&gt;2.5.0&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p><strong>application.properties</strong></p>
  
  <pre><code>server.port=10080
  server.contextPath=/approot
  
  ------------------Hibernate Datasource configuration------------------
  spring.datasource.url=${.service.jdbc.url}
  spring.datasource.username=${service.jdbc.username}
  spring.datasource.password=${service.jdbc.password}
  spring.datasource.driver-class-name=${service.jdbc.driver}
  
  spring.jpa.hibernate.ddl-auto: update
  spring.jpa.hibernate.naming_strategy: org.hibernate.cfg.ImprovedNamingStrategy
  spring.jpa.show-sql: false
  
  ------------------Tomcat Access logs------------------
  server.tomcat.accessLogEnabled=true
  server.tomcat.accessLogPattern=%t responseTime=%D remoteHost=%h %l thread=%I %u method=%m uri=%U status=%s bytes=%b
  server.tomcat.basedir=/var/log/tomcat-access
  
  error.whitelabel.enabled=false
  </code></pre>
  
  <p>When I am trying to access the URL <code>http://localhost:10080/approot/swagger-ui.html</code>, I am getting below error and nothing displayed on the web page.</p>
  
  <pre><code>Aug 08, 2016 11:48:05 AM org.apache.catalina.core.ApplicationDispatcher invoke
  SEVERE: Servlet.service() for servlet dispatcherServlet threw exception
  javax.servlet.ServletException: Circular view path [error]: would dispatch back to the current handler URL [/approot/error] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
      at org.springframework.web.servlet.view.InternalResourceView.prepareForRendering(InternalResourceView.java:205)
      at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:145)
      at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
      at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1228)
      at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1011)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:955)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
      at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:721)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:468)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:391)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:318)
      at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:433)
      at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:299)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:176)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)
      at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Unknown Source)
  
  Aug 08, 2016 11:48:05 AM org.apache.catalina.core.StandardHostValve custom
  SEVERE: Exception Processing ErrorPage[errorCode=0, location=/error]
  javax.servlet.ServletException: Circular view path [error]: would dispatch back to the current handler URL [/approot/error] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
      at org.springframework.web.servlet.view.InternalResourceView.prepareForRendering(InternalResourceView.java:205)
      at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:145)
      at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
      at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1228)
      at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1011)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:955)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
      at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:721)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:468)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:391)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:318)
      at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:433)
      at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:299)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:176)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)
      at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Unknown Source)
  </code></pre>