Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Debugging status=500 on url pointing into project(Debugging addressing difficulty with Spring Tools project)
Debugging status=500 on url pointing into project [message #1839099] Sat, 13 March 2021 22:45 Go to next message
Phil Freihofner is currently offline Phil FreihofnerFriend
Messages: 46
Registered: May 2010
I have an image file that is stored in a file folder that is part of a Spring Tools project. My program is able to load a selected .png into this folder, and to delete files within this folder, but when I try to reference the file in this folder to display the image, I get a "status=500" error.

Any thoughts on how to go about debugging this?
My web server is Tomcat on Ubuntu 20.04.

The failing URL:

The error message (first few lines only, none of the lines refer to code that was written for the project):
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Sat Mar 13 13:36:00 PST 2021
There was an unexpected error (type=Internal Server Error, status=500).
home home
	at java.base/
	at java.base/
	at java.base/
	at java.base/
	at java.base/
	at java.base/
	at java.base/
	at java.base/

Image of screen with Package/ProjectExplorer showing location of folder "user-photos" in the project:

File location:

When the project server is launched, the initial console comments include the following reference to home:
Starting ShopmeBackendApplication using Java 15.0.1 on UbuntuDesktop with PID 11957 (/home/phil/bin/SpringTools/workspace/ShopmeProject/ShopmeWebParent/ShopmeBackend/target/classes started by phil in /home/phil/bin/SpringTools/workspace/ShopmeProject/ShopmeWebParent/ShopmeBackend)

The following code was written to make the file location accessible:
import java.nio.file.Path;
import java.nio.file.Paths;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

public class MvcConfig implements WebMvcConfigurer {

	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		String dirName = "user-photos";
		Path userPhotosDir = Paths.get(dirName);
		String userPhotosPath = userPhotosDir.toFile().getAbsolutePath();
		System.out.println("MvcConfig.userPhotosPath:" + userPhotosPath);
		registry.addResourceHandler("/" + dirName + "/**")
			.addResourceLocations("file:/" + userPhotosPath + "/");

The line that is output from the above follows:

The same git project works when run on a Windows system, so I'm wondering if there is something in how Eclipse or Spring or Tomcat is configured on Ubuntu that might be the cause the problem. I've searched for instances where the string "home" appears in the project, but the references are in the batch (bash) files "mvnw" or in a library that shouldn't matter (e.g., fontawesome). I am at a loss as to how to proceed.
Re: Debugging status=500 on url pointing into project [message #1839100 is a reply to message #1839099] Sat, 13 March 2021 23:28 Go to previous messageGo to next message
Thomas Wolf is currently offline Thomas WolfFriend
Messages: 397
Registered: August 2016
Senior Member
Use valid file URL: file:///home/phil/.... (three slashes). Your URL has two slashes and thus "home" is taken as a host name.
Re: Debugging status=500 on url pointing into project [message #1839102 is a reply to message #1839100] Sun, 14 March 2021 01:22 Go to previous message
Phil Freihofner is currently offline Phil FreihofnerFriend
Messages: 46
Registered: May 2010
Thank you! Your answer worked.

I didn't understand why this worked, so I spent some time searching for syntax info, and found the following:


A file URI takes the form of


where host is the fully qualified domain name of the system on which the path is accessible, and path is a hierarchical directory path of the form directory/directory/.../name. If host is omitted, it is taken to be "localhost", the machine from which the URL is being interpreted. Note that when omitting host, the slash is not omitted (while "file:///foo.txt" is valid, "file://foo.txt" is not, although some interpreters manage to handle the latter).

So, in the three-slash URL, the "host" part was omitted and "localhost" was presumed, and the position of the "localhost" would have been in between the 2nd and 3rd slashes.

After reading the above, I also tried the following and found that it also was successful.
registry.addResourceHandler("/" + dirName + "/**")
			.addResourceLocations("file:" + userPhotosPath + "/");

I'm guessing that in this case the system again treats this as an "omitted host" situation and therefore make use of "localhost". Your three-slash form feels a little more explicit, so I'm going to chose it over the one-slash form.
Previous Topic:error while downloading web-app_4_0.xsd in dynamic web app eclipse
Next Topic:Eclipse Installer 2020-06 crashes on MacOs Big Sur
Goto Forum:

Current Time: Thu Jul 29 01:57:36 GMT 2021

Powered by FUDForum. Page generated in 0.02723 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top