4

I have a spring boot application that is throwing the following:

2018-01-14 01:02:56.863 ERROR 372 --- [io-8080-exec-14] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause

The application runs and behaves as expected. I've seen the error in the logs a few times but can't seem to see why/where its happening.

There is no other information in the log about the error.

I've had a look at the logs to see what happened before and after the error occurred and everything seemed fine.

I have also turned the log level to ALL and still the no useful error message.

Any ideas why I am getting this error and how I can get my application to throw more useful errors.

What stand out from the error message is with path [] threw exception. I'm not sure what [] is.

breaktop
  • 1,899
  • 4
  • 37
  • 58
  • i am getting the same issue without stacktrace can you please tell me how you got the trace in Spring boot ? – Manjunath Nov 04 '19 at 10:05

2 Answers2

3

Any ideas why I am getting this error and how I can get my application to throw more useful errors.

The root cause is a NullPointerException (NPE) thrown at some point in the call stack of the DispatcherServlet.

Unfortunately, you don't get a complete stacktrace of the NPE in your log. Have you checkout the standard output for the stacktrace? Normally Spring Boot is really conservative configured when it comes to swallowing stacktraces. Meaning: there should be a point where you can see the complete stacktrace. My guess: a logfile in the working directory or the standard output of the application (e.g. terminal screen).

What stand out from the error message is with path [] threw exception. I'm not sure what [] is.

This is the path part of the request. [] means the path is an empty string. Spring used the []-notation to signal you that there is an empty string. Normally it would look like [/users/34]. My guess is: you called something like http://localhost:8080 so no trailing slash is present, which renders the path part of the url to an empty string.

Johannes Leimer
  • 1,339
  • 12
  • 23
-5

I had the same issue and was able to resolve it by using another JDK.

I switched from openjdk 8 to openjdk 9 (both ubuntu 18.04) by running

sudo apt install default-jdk

(check if it update your symlinks with java -version

Chris K.
  • 1,060
  • 8
  • 10