title: How to resolve the requested resource is not available error in spring boot which runs on tomcat server?
body: <p>I had successfully run my spring boot application in localhost.</p>
  <p><a href="https://i.stack.imgur.com/EAl6I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EAl6I.png" alt="enter image description here" /></a></p>
  <p>But when I had run it from the CWP panel tomcat server, I am getting the error given below. How to resolve this error? Do I need anything else to run on a CWP panel tomcat server?</p>
  <p><a href="https://i.stack.imgur.com/QODEC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QODEC.png" alt="enter image description here" /></a></p>
  <p>Steps which I had followed</p>
  <ol>
  <li><p>Extends the SpringBootServletInitializer class in the main class.</p>
  <pre><code>@SpringBootApplication
  public class GDriveAppJavaApplication extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure( SpringApplicationBuilder builder) {
       return builder.sources(GDriveAppJavaApplication.class);
    }
   public static void main(String[] args) {
      SpringApplication.run(GDriveAppJavaApplication.class, args);
    }
  
  }
  </code></pre>
  </li>
  <li><p>Update packaging JAR to WAR</p>
  </li>
  <li><p>Added Tomcat starter dependency with scope as provided</p>
   
  <pre><code> &lt;dependency&gt;
       &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
       &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
       &lt;scope&gt;provided&lt;/scope&gt;
   &lt;/dependency&gt;
  </code></pre>
  </li>
  <li><p>Application properties</p>
  <pre><code> server.servlet.context-path=/GDriveAppJava
  </code></pre>
  </li>
  <li><p>Generated war file(GDriveAppJava) and copied to webapps folder in the tomcat as shown below.</p>
  </li>
  </ol>
  <p><a href="https://i.stack.imgur.com/Tbp5K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Tbp5K.png" alt="enter image description here" /></a></p>
  <ol start="6">
  <li><p>Controller file</p>
  <pre><code>@RestController
  @AllArgsConstructor
  public class FileController {
  
     @Autowired
     private FileManager fileManager;
  
     @Autowired
     private FileRepository fileRepository;
  
     @PostMapping(value = &quot;/upload/{user_id}&quot;)
     public ResponseEntity&lt;FileEntity&gt; uploadFIle(@RequestParam(&quot;file&quot;) MultipartFile file,@PathVariable String user_id){
         FileEntity updated = fileManager.uploadFile(file, user_id);
         return new ResponseEntity&lt;FileEntity&gt;(updated, HttpStatus.OK);
     }
  
     @GetMapping(path=&quot;/viewByUserId/{user_id}&quot;)
     public List&lt;FileEntity&gt; viewByUserid(@PathVariable String user_id) 
     {
          return fileRepository.findByUserId(user_id);
     }
  
     @GetMapping(&quot;/downloadFile/{file_id}&quot;)
     public void download(@PathVariable String file_id, HttpServletResponse response) throws IOException, GeneralSecurityException {
        fileManager.downloadFile(file_id, response.getOutputStream());
     }
  
     @GetMapping(path=&quot;/viewByFileId/{file_id}&quot;)
     public List&lt;FileEntity&gt; viewByFileId(@PathVariable String file_id) 
     {
        return fileRepository.findByFileId(file_id);
     }
  </code></pre>
  <p>}</p>
  </li>
  </ol>
  <p><strong>Application properties</strong></p>
  <pre><code>spring.jpa.hibernate.ddl-auto=update
  spring.datasource.url=jdbc:jdbc:mysql://${MYSQL_HOST:localhost}:3306/user123_gdriveapp
  spring.datasource.username=user123//my server username
  spring.datasource.password=password123//my server password
  spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
  spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
  spring.jpa.show-sql: true
  
  
  spring.servlet.multipart.max-file-size=100MB
  spring.servlet.multipart.max-request-size=100MB
  
  server.servlet.context-path=/GDriveAppJava
  
  
  
  
  
  
  
          
  </code></pre>