Issue With Spring: There was an unexpected error (type=Not Found, status=404)

whitelabel error page 404 spring boot solution
there was an unexpected error (type=not found status=404). no message available in spring boot
there was an unexpected error (type=not found, status=404 jsp)
status'': 404, error'': not found'', message'': no message available
how to resolve 404 error in spring boot
how to resolve whitelabel error page in spring boot application
http status 404 – not found spring mvc
http status 404 – not found spring boot

I am going through this book on restful web services with spring. I decided to move away from what they were doing and use java configuration files. For some reason, after switching over to the Java configuration, the service would run (in the console window) correctly but when I actually go to the endpoint on localhost i get this:

White label Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Sat Apr 23 20:48:25 PDT 2016 There was an unexpected error (type=Not Found, status=404). No message available

And this is the response from the GET request:

{
    "timestamp": 1461470029110,
    "status": 404,
    "error": "Not Found",
    "message": "No message available",
    "path": "/greeting"
}

The next chapter of this story begins with me going to the getting started page on the Spring website http://spring.io/guides/gs/rest-service/ I decided to start a small project recreating their basic tutorial. I will post the code I wrote below for you to see. The problem is, I am having the exact same issue. The service runs but I can't hit the endpoints. I am not sure what is going on and I have seen others with similar issues, but the answers have not applied/helped with mine. I am sure it is something obvious that I am doing wrong and any help would be greatly appreciated. One last piece of information, if at all relevant, I am using IntelliJ IDEA 15 CE as my IDE.

The endpoint being hit:

http://localhost:8080/greeting

My controller

@RestController
public class GreetingController {
    private static final String template = "Hello, %s!";
    private final AtomicLong counter = new AtomicLong();

    @RequestMapping("/greeting")
    public Greeting greeting(@RequestParam(value = "name", defaultValue = "World")String name) {
        return new Greeting(counter.incrementAndGet(), String.format(template, name));
    }
}

My Resource Representation class

public class Greeting {
    private final long id;
    private final String content;

    public Greeting(long id, String content) {
        this.id = id;
        this.content = content;
    }

    public long getId() {
        return id;
    }

    public String getContent() {
        return content;
    }
}

My Main

@SpringBootApplication
public class Application
{
    public static void main(String[] args)
    {
        SpringApplication.run(Application.class, args);
    }
}

My POM file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.organization_name.webservices</groupId>
<artifactId>helloworld</artifactId>
<version>1.0-SNAPSHOT</version>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.3.RELEASE</version>
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

<properties>
    <java.version>1.8</java.version>
</properties>


<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

<repositories>
    <repository>
        <id>spring-releases</id>
        <url>https://repo.spring.io/libs-release</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-releases</id>
        <url>https://repo.spring.io/libs-release</url>
    </pluginRepository>
</pluginRepositories>

Command line to run

mvn spring-boot:run   

My complete log from the console

 .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.3.3.RELEASE)

2016-04-23 20:47:53.153  INFO 7898 --- [           main] c.t.webservices.application.Application  : Starting Application on Macintosh.local with PID 7898 (/Users/<my_user>/Downloads/B04788_Code/HelloWorld/target/classes started by <my_user> in /Users/<my_user>/Downloads/B04788_Code/HelloWorld)
2016-04-23 20:47:53.156  INFO 7898 --- [           main] c.t.webservices.application.Application  : No active profile set, falling back to default profiles: default
2016-04-23 20:47:53.242  INFO 7898 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@68ceda24: startup date [Sat Apr 23 20:47:53 PDT 2016]; root of context hierarchy
2016-04-23 20:47:54.084  INFO 7898 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'beanNameViewResolver' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2016-04-23 20:47:54.811  INFO 7898 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2016-04-23 20:47:54.840  INFO 7898 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2016-04-23 20:47:54.841  INFO 7898 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.0.32
2016-04-23 20:47:54.960  INFO 7898 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2016-04-23 20:47:54.960  INFO 7898 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1736 ms
2016-04-23 20:47:55.214  INFO 7898 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]
2016-04-23 20:47:55.218  INFO 7898 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-04-23 20:47:55.219  INFO 7898 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-04-23 20:47:55.219  INFO 7898 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-04-23 20:47:55.219  INFO 7898 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'requestContextFilter' to: [/*]
2016-04-23 20:47:55.545  INFO 7898 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@68ceda24: startup date [Sat Apr 23 20:47:53 PDT 2016]; root of context hierarchy
2016-04-23 20:47:55.605  INFO 7898 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2016-04-23 20:47:55.606  INFO 7898 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2016-04-23 20:47:55.628  INFO 7898 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-04-23 20:47:55.628  INFO 7898 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-04-23 20:47:55.657  INFO 7898 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-04-23 20:47:55.776  INFO 7898 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2016-04-23 20:47:55.848  INFO 7898 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2016-04-23 20:47:55.853  INFO 7898 --- [           main] c.t.webservices.application.Application  : Started Application in 3.531 seconds (JVM running for 4.702)
2016-04-23 20:48:19.521  INFO 7898 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2016-04-23 20:48:19.521  INFO 7898 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2016-04-23 20:48:19.533  INFO 7898 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 12 ms

Console update after GET request

2016-04-23 20:48:19.521  INFO 7898 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2016-04-23 20:48:19.533  INFO 7898 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 12 ms

Console after stopping

2016-04-23 20:53:24.494  INFO 7898 --- [       Thread-2] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@68ceda24: startup date [Sat Apr 23 20:47:53 PDT 2016]; root of context hierarchy
2016-04-23 20:53:24.495  INFO 7898 --- [       Thread-2] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

Process finished with exit code 130

Thanks again for any help you can offer. I will keep everyone posted with updates!

I believe your issue is related to packages. Your application is defined in com.organization_name.webservices.application. I am guessing your other classes are in a different package that is not a child of com.organization_name.webservices.application. Spring will automatically load controllers that are in the same package or sub-packages, for example:

com.organization_name.webservices.application
com.organization_name.webservices.application.controllers

But not packages like this:

com.organization_name.webservices.controllers

You can fix this by either moving your controller (or application), or adding ComponentScan to your Application:

@SpringBootApplication
@ComponentScan(basePackageClasses=GreetingController.class)
public class Application {

You should be seeing this in your log:

 Mapped "{[/greeting]}" onto public com.organization_name.webservices.xxx.Greeting com.organization_name.webservices.xxx.GreetingController.greeting(java.lang.String)

Spring Boot "No message available" error(status = 404),, But http://localhost:8090/home gives me an error 404. There was an unexpected error (type=Not Found, status=404). No message available. Application.java @� Spring boot Oauth2 Facebook login - JSON parse error: Cannot deserialize instance of `java.lang.String` out of START_OBJECT token Hot Network Questions Why struggle for a single pawn?

seems like you are missing thymleaf dependency. Put this inside your pom.xml dependencies

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

Getting Whitelabel Error Page with status "404" While running , Sat Apr 13 10:34:51 IST 2019 There was an unexpected error (type=Not Found, status=404). No message available. Spring Boot Application� With the above setup, by default, Spring looks for all your REST controllers in subpackages of hotelapp. As there are no subpackages under it, it says that the url mapping is not found and returns a 404. To resolve this, there are 2 options – a. Move your REST controllers to a subpackage under your Spring boot app package as shown below. b.

in pom.xml add the following dependency

     <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <scope>provided</scope>
    </dependency>

There was an unexpected error (type=Not Found, status=404 , Successfully merging a pull request may close this issue. None yet. 4 participants . @snicoll � @kjoshi07 � @spring-issuemaster � @jimmehta. Solution. Bootstrap class Application.java should know the package or the class path where it should refer in order access the controller.. Hence you need to specify @ComponentScan(basePackages= {"com.technicalkeeda"} on top of your Bootstrap class.

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Mon May 04 08:30:07 IST 2020 There was an unexpected error (type=Not Found, status=404). No message available

This application has no explicit mapping for /error, so you are seeing , There was an unexpected error No message available. Fri Apr 10 22:45:19 IST 2020 There was an unexpected error (type=Not Found, status=404). The spring boot main class will be created in the “com.yawintutor.application” package. Identify the loading issue of the controller or method, disable the error page from� When I try to translate a project into Spring Boot, I get an error-I can not understand what I did wrong. The suffix and prefix added to the property-file, tried to change the location of jsp,debager shows that in the controller's method comes.

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Mon May 04 09:16:36 IST 2020 There was an unexpected error (type=Not Found, status=404). No message available

Issue – There was an unexpected error (type=Not Found, status=404)., Issue – There was an unexpected error (type=Not Found, status=404). With the above setup, by default, Spring looks for all your REST� I just discovered that it seems to be an issue with the current working directory, because if I start the app manually from some arbitrary directory and provide the absolute path to the jar, the behavior is the same as if started by cygrunsrv.

spring: thymeleaf: There was an unexpected error (type=Not Found , spring: thymeleaf: There was an unexpected error (type=Not Found, status=404). >PROBLEM Pointing to URL returns 404. Whitelabel Error� The problem is even when I'm trying to run the simplest quick-start Spring Boot projects, I'm facing exceptions. Here's exception log when I tried to load the example from mkyong site. I tried to manage maven dependencies manually, as I browsed through some "potential" solutions and found that it could be jar conflict.

Failing to understand how Spring Boot and Spring MVC works, From what I understand in very basic cases Spring Boot should cover me and " web.xml" is not even neccesary, is that right? No luck, now I get "There was an unexpected error (type=Not Found, status=404). If I have been stuck on a java Stack textbook problem for one month (giving the problem one to two hours of� Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. There was an unexpected error No message available

How to Disable Whitelabel Error Page in Spring Boot, There was an unexpected error (type=Not Found, status=404). No message available. There are several ways to switch the default whitelabel� Failing to understand how Spring Boot and Spring MVC works I am trying to create very basic "hello world" application following multiple tutorials I found on web. So far I created Spring project in Idea using start.spring.io and changed some stuff a bit, but I fail to understand how it handles "jsp" files and how am I supposed (if supposed) to

Comments
  • Just to be clear - you are seeing the whitelabel error page when you go to localhost:8080/greeting or just localhost:8080? I see the same when I go to localhost:8080, but it works just fine when I go to /greeting.
  • good question, I should have been more clear. Yes, the GET is made towards the endpoint itself, localhost:8080/greeting I updated the question to reflect that now :)
  • Had to additionally add: import org.springframework.context.annotation.ComponentScan; import main.java.hello.GreetingController;
  • Sometimes this error will also appear if your request mapping is not handled by any controller.
  • Thanks, this is really helpful!