My computer restarted and my app no longer works today. It was working yesterday. Nothing changed except Maven downloading new libraries (mostly Amazon). Now I can't even access the /admin/login
page. How do I debug the request?
2019-09-13 17:26:16.924 INFO 2056 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/admin/login],methods=[GET]}" onto public java.lang.String com.s.s.controller.Controller.login()
2019-09-13 17:26:21.465 ERROR 2056 --- [nio-8080-exec-1] c.s.s.c.Controller : invalidRequest(): invalid request: /admin/login
@RequestMapping(value="/admin/login", method=RequestMethod.GET)
public String login() {
return "login";
}
@RequestMapping("/error")
public void invalidRequest(HttpServletRequest request, HttpServletResponse response){
Logger.error(TAG, "invalidRequest()", "invalid request: " + request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI));
try {
response.setStatus(HttpStatus.OK.value());
response.getWriter().write("This is not a valid request");
} catch (IOException e) {
Logger.error(TAG, "invalidRequest: ", "Exception in invalidRequest() method "+e.getMessage());
}
}
@Override
public String getErrorPath() {
return "/error";
}
I set this line in application.properties
but it didn't print anything extra.
logging.level.com.s.s.controller.Controller=DEBUG
I ran mvn clean
and restarted server, but it didn't help.
I set this line in application.properties
but it didn't print anything useful.
debug=true
Log:
2019-09-13 17:40:25.459 DEBUG 2056 --- [nio-8080-exec-1] o.s.b.w.f.OrderedRequestContextFilter : Bound request context to thread: org.apache.catalina.connector.RequestFacade@4d3e8c3a
2019-09-13 17:40:25.460 DEBUG 2056 --- [nio-8080-exec-1] o.s.b.w.f.OrderedRequestContextFilter : Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@4d3e8c3a
2019-09-13 17:40:25.463 ERROR 2056 --- [nio-8080-exec-1] c.s.s.c.Controller : invalidRequest(): invalid request: /admin/login
2019-09-13 17:40:25.477 DEBUG 2056 --- [nio-8080-exec-2] o.s.b.w.f.OrderedRequestContextFilter : Bound request context to thread: org.apache.catalina.connector.RequestFacade@4d3e8c3a
2019-09-13 17:40:25.484 DEBUG 2056 --- [nio-8080-exec-2] o.s.b.w.f.OrderedRequestContextFilter : Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@4d3e8c3a
$ git status
modified: src/main/resources/application.properties
modified: src/main/resources/static/js/home.js
I compared libraries to what was last deployed and the only changes were
aws-java-sdk-core-1.11.631.jar
aws-java-sdk-kms-1.11.631.jar
aws-java-sdk-s3-1.11.631.jar
aws-java-sdk-ses-1.11.631.jar
jmespath-java-1.11.631.jar
I commented public String getErrorPath()
and public void invalidRequest()
and now it gives me
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Fri Sep 13 18:59:03 UTC 2019
There was an unexpected error (type=Forbidden, status=403).
No message available
But with curl
it gives
$ curl localhost:8080/admin/login
{"timestamp":1568401131164,"status":403,"error":"Forbidden","message":"No message available","path":"/admin/login"}
I found the following searching for spring-sleuth
in Makgigrahul's answer and added it to application.properties
producing this log.
logging.level.org.springframework.web.servlet.DispatcherServlet=DEBUG
Log:
2019-09-13 16:10:11.329 DEBUG 15356 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing servlet 'dispatcherServlet'
2019-09-13 16:10:11.330 INFO 15356 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2019-09-13 16:10:11.331 INFO 15356 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2019-09-13 16:10:11.332 DEBUG 15356 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Using MultipartResolver [org.springframework.web.multipart.support.StandardServletMultipartResolver@6481dcd8]
2019-09-13 16:10:11.332 DEBUG 15356 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Using LocaleResolver [org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver@50cc90f2]
2019-09-13 16:10:11.339 DEBUG 15356 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Unable to locate ThemeResolver with name 'themeResolver': using default [org.springframework.web.servlet.theme.FixedThemeResolver@135fd762]
2019-09-13 16:10:11.345 DEBUG 15356 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Unable to locate RequestToViewNameTranslator with name 'viewNameTranslator': using default [org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator@61cc4a6b]
2019-09-13 16:10:11.352 DEBUG 15356 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Unable to locate FlashMapManager with name 'flashMapManager': using default [org.springframework.web.servlet.support.SessionFlashMapManager@766c1f26]
2019-09-13 16:10:11.353 DEBUG 15356 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Published WebApplicationContext of servlet 'dispatcherServlet' as ServletContext attribute with name [org.springframework.web.servlet.FrameworkServlet.CONTEXT.dispatcherServlet]
2019-09-13 16:10:11.355 INFO 15356 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 23 ms
2019-09-13 16:10:11.356 DEBUG 15356 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Servlet 'dispatcherServlet' configured successfully
2019-09-13 16:10:11.376 DEBUG 15356 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/error]
2019-09-13 16:10:11.383 DEBUG 15356 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Last-Modified value for [/error] is: -1
2019-09-13 16:10:11.408 DEBUG 15356 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Rendering view [org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$SpelView@53191939] in DispatcherServlet with name 'dispatcherServlet'
2019-09-13 16:10:11.415 DEBUG 15356 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Successfully completed request
org.apache.catalina.core.ApplicationFilterChain#doFilter()
method.org.springframework.web.servlet.DispatcherServlet#doDispatch()
method.