I have created a JavaEE based web application that I then exported as a WAR file and deployed to a tomcat server that is running on a vm.
The Application allows users to upload an image to a location on the vm disk, and then to run an image processing class that accepts a path to the previously uploaded file.
I am trying to use ImageIO.read() to read in the file as a buffered image.
When running in the IDE, the image processing class works fine and is able to accept the image stored on the disk and output the processed image. However when accessing it as a deployed web application I am met with the error:
HTTP Status 500 - Can't read input file!
type Exception report
message Can't read input file!
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.imageio.IIOException: Can't read input file!
javax.imageio.ImageIO.read(Unknown Source)
upload.servlet.resizeImageAndSaveSobel2.sobelFilter(resizeImageAndSaveSobel2.java:22)
upload.servlet.resizeImageAndSaveSobel2.processImage(resizeImageAndSaveSobel2.java:14)
upload.servlet.RunTongue.doPost(RunTongue.java:24)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
note The full stack trace of the root cause is available in the Apache Tomcat/9.0.0.M13 logs.
This is the code which is a part of the image processing class that reads in the uploaded image:
public void sobelFilter(String input, String output) throws IOException {
File inputFile = new File(input);
BufferedImage img = ImageIO.read(inputFile);
ImageReader ir = new ImageReader();
BufferedImage sobelImg = ir.greyscale(img);
File outputFile = new File(output);
ImageIO.write(sobelImg, "jpg", outputFile);
}
The input file string is as follows: C:/Users/SRCMIPS/Desktop/M2/Image Upload/PatientImage.jpeg
Is this a problem regarding ImageIO.read with a deployed WAR of the project? Is the application unable to read in images from paths located on the vm?
Any guidance with regards to a solution to this problem would be appreciated.