• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

image can't handled by spring boot REST framework on external tomcat on POST method. Return 404 erro

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am working with the following environment. 1. IDE eclipse mars(4.5.2) 2. Gradle 3. Spring boot (tomcat is embedded) 4. Angular Js with grunt.

Problem : I want to upload image on AWS S3. When I ran on locally with embedded tomcat with "spring bootrun" command and upload the file from bowser /Postman API call, the image uploaded fine.

But when I make war file by gradle war command and run it inside tomcat 7 or tomcat 8 and go for same task, the rest controller of spring boot framework could not find the image file.

Please help me to overcome this strange issue.

File information :

public class ProfileImageUploadController extends BaseController {

   private ImageStoreOnAws imageStoreOnAws;

   @RequestMapping(value = "/upload", method = RequestMethod.POST)
   public ResponseEntity<Map<String, Object>> getPictureUploadUrl(@AuthenticationPrincipal OttaAccountDetails principal, MultipartHttpServletRequest request) {
       Map<String, Object> response = new HashMap<>();
       System.err.println("\nagain info---------------->"+request.getRequestURI());
       MultipartFile multiFile = request.getFile("profile_pic");
       System.err.println("Multipart file --------->"+multiFile);
       System.err.println("\n Content Type --------->"+request.getContentType());

       //String pictureUploadUrl = displayPictureImageStore.uploadUrl("/session/picture/" + principal.getUserId(), 10485760);
       response = imageStoreOnAws.uploadProfilePicture(principal.getUserId(), multiFile);
       return new ResponseEntity(response, HttpStatus.OK);

Postman API call : http://localhost:8080/profilePicture/upload (it works fine locally. But when I ran inside tomcat with war it does not work locally)

Gradle file (Portion of code) :

apply plugin: 'war'
   war {
       baseName = 'otta-web'
       version = '1.0-SNAPSHOT'
   version = '1.0-SNAPSHOT'

   bootRepackage.enabled = false;
   bootRun.enabled = true;

Output : The print gives the following output.

   REQUEST---------------->1818 again info---------------->/profilePicture/upload Multipart file --------->null Content Type --------->multipart/form-data; boundary=--------------------------182405819892384390851841

The exact output should be like below :


   again info---------------->/profilePicture/upload Multipart file --------->org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile@181b1cf4

   Content Type --------->multipart/form-data; boundary=--------------------------341504561441584510876671

Author and all-around good cowpoke
Posts: 13078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the rest controller of spring boot framework could not find the image file.

Why do you think it can't find the image file?
A reply status of 404 to me indicates it could not find the service. Are you sure it is finding the controller service?

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic