title: I am trying to load a jsp using spring boot with gradle but I am only getting internal server error
body: <p>I am new to spring boot and trying to load a jsp page but even after trying a lot and searching on internet I couldn't find any solution of it. I am unable to get  the error causing part in this complete process.</p>
  
  <p>To build this all I used command 'gradle build' on command prompt.</p>
  
  <p>To start the server I used command :- java -jar build\libs\one-0.0.1-SNAPSHOT.war</p>
  
  <p>then I on browser I typed :- <a href="http://localhost:8080/helloWorld" rel="nofollow noreferrer">http://localhost:8080/helloWorld</a></p>
  
  <p>Here is my build.gradle</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>plugins {
   id 'org.springframework.boot' version '2.2.2.RELEASE'
   id 'io.spring.dependency-management' version '1.0.8.RELEASE'
   id 'java'
   id 'war'
  }
  
  group = 'com.tm'
  version = '0.0.1-SNAPSHOT'
  sourceCompatibility = '1.8'
  
  configurations {
   developmentOnly
   runtimeClasspath {
    extendsFrom developmentOnly
   }
  }
  
  repositories {
   mavenCentral()
  }
  
  dependencies {
   implementation 'org.springframework.boot:spring-boot-starter-actuator'
   implementation 'org.springframework.boot:spring-boot-starter-web'
    providedRuntime 'javax.servlet:jstl'
    providedRuntime 'org.apache.tomcat.embed:tomcat-embed-jasper'
   implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
   developmentOnly 'org.springframework.boot:spring-boot-devtools'
  
   testImplementation('org.springframework.boot:spring-boot-starter-test') {
    exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
   }
  }
  
  test {
   useJUnitPlatform()
  }</code></pre>
  </div>
  </div>
  </p>
  
  
  
  <p>This is my java code of controller HelloJSPController.java, it is in this folder structure: \src\main\java\com\tm\one </p>
  
  <pre><code>package com.tm.one;
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.web.bind.annotation.GetMapping;
  import org.springframework.web.bind.annotation.RequestParam;
  @Controller
  public class HelloJSPController 
  {
   @GetMapping("/helloWorld")
   public String helloWorld()  
    {
      return "helloWorld";
    }
  }
  </code></pre>
  
  <p>This is WebMvcConfig.java configuration file</p>
  
  <pre><code>package com.tm.one.config;
  
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
  import org.springframework.web.servlet.config.annotation.EnableWebMvc;
  import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
  import org.springframework.web.servlet.view.InternalResourceViewResolver;
  
  @Configuration
  public class WebMvcConfig extends WebMvcConfigurerAdapter
  {
   @Bean
   public InternalResourceViewResolver viewResolver() 
    {
       InternalResourceViewResolver resolver = new InternalResourceViewResolver();
       resolver.setPrefix("/WEB-INF/jsp/");
       resolver.setSuffix(".jsp");
       return resolver;
    }
  
   } 
  </code></pre>
  
  <p>OR I tried this two lines in application.propertes also instead of above configuration file </p>
  
  <blockquote>
    <p>spring.mvc.view.prefix=/WEB-INF/jsp/<br>
      spring.mvc.view.suffix=.jsp</p>
  </blockquote>
  
  <p>This is JSP file helloWorld.jsp in folder structure :--  \one\src\main\webapp\WEB-INF\jsp</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;Hello&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h2&gt;Hello everyone I am AD&lt;/h2&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is error I am getting on browser</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>Whitelabel Error Page
  This application has no explicit mapping for /error, so you are seeing this as a fallback.
  
  Mon Jan 13 16:53:14 IST 2020
  There was an unexpected error (type=Internal Server Error, status=500).
  Error resolving template [helloWorld], template might not exist or might not be accessible by any of the configured Template Resolvers</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is OneApplication.java</p>
  
  <pre><code>package com.tm.one;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.boot.builder.SpringApplicationBuilder;     
  import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;  
  
  @SpringBootApplication
  
  
      public class OneApplication extends SpringBootServletInitializer {
  
          public static void main(String[] args) {
              SpringApplication.run(OneApplication.class, args);
          }
  
  
      @Override
          protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
              return application.sources(OneApplication.class);
          }
  
  
      }
  </code></pre>