Thymeleaf Spring Property or field '' cannot be found on null - spring

I am working on a project with Thymeleaf, Spring and Angular. I have a span in my html file which is as follows:
<span ng-if="isFurious == '1'" th:text="#{furious-message(${furious_bdate}, ${furious.edate)}" style="color:red;font-weight:bold;"></span>
And the relevent message property as follows:
furious-message=Object was from {0} till {1} in furious
I get the following error when page is loaded
**Whitelabel Error Page**
This application has no explicit mapping for /error, so you are seeing this as a fallback.
There was an unexpected error (type=Internal Server Error, status=500).
Exception evaluating SpringEL expression: "document.begin_date" (units:205)
In my Java console I have the following error:
Property or field 'bdate' cannot be found on null
'bdate' and 'edate' are coming from angular controller.
Kindly let me know if what am I doing wrong.
Thanks and Regards.

Related

Creating security for web application issue in the code for logging into the page

I was building spring security web application using "https://spring.io/guides/gs/securing-web/" but im getting error as " Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Dec 20 11:47:42 IST 2022
There was an unexpected error (type=Internal Server Error, status=500). "pls help!!
i tried to add some jsp dependencies / to use # configuration but still same error and i am expecting the message to be displayed

Swagger-ui error HttpMediaTypeNotAcceptableException

I am trying to add a Spring fox Swagger UI to my existing Spring Boot project.
My issue is that all the paths are working normally like "/v2/api".. except for "/swagger-ui.html".
The error I get everytime is :
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Oct 30 11:11:37 CET 2019
There was an unexpected error (type=Not Acceptable, status=406).
Could not find acceptable representation
and the error in debut :
org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
When I tried to handle the exception on my Exception Handler, I found that the acceptable type is "application/json" as I use Spring MVC.
Any idea how to resolve that ?
cheers.

Using Vaadin Error View instead of Spring Boot's Whitelabel error page

I'm using Spring Boot with Vaadin and. By using the #Autowired SpringNavigator, I have also set the error view:
navigator.setErrorView(ErrorView.class);
But when I type wrong URL like http://localhost:8080/asdf .
I always get the Spring Boot's Whitelabel error page. I know that I can set custom HTML page for the error like
/resources/public/error/404.html
but this is HTML way, I would like to use Vaadin with components,
the best solution would be the mentioned error view.

Spring Boot Tutorial - Error when trying to check service

I followed steps given in https://spring.io/guides/gs/spring-boot/ for building a springboot application. I am using intellij & Maven, Application started without any errors but when i tried to access hpp://localhost:8080. I am getting an error as below
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Aug 21 08:01:16 IST 2017
There was an unexpected error (type=Not Found, status=404).
No message available
It's mostly likely that either the #RestController or #RequestMapping annotations are missing from your controller class.
You can compare you code to the completed example here, to see if there's anything missing:
https://github.com/spring-guides/gs-spring-boot/blob/master/complete/src/main/java/hello/HelloController.java

Force Spring to always report exceptions as JSON

How do I force Spring to always convert uncaught exception to JSON instead of HTML page?
This is what I get when request is made from Chrome's REST client plugin:
{
timestamp: 1425041457798
status: 404
error: "Not Found"
exception: "com.some.my.Exception"
message: "/rrr does not exist"
path: "/test/rrr"
}
But this is what I get when I access it from browser or from Jersey API (you see parsed HTML):
Whitelabel Error PageThis application has no explicit mapping for /error, so you are seeing this as a fallback.Fri Feb 27 13:37:27 CET 2015There was an unexpected error (type=Not Found, status=404).No message available
I know this can be done somehow by setting the request headers but I want JSON response to be the only variant.
First we need add some exception resolver for exception that trows inside controllers. I prefer extend ResponseEntityExceptionHandler and add own method, but there is a great article on spring.io: http://spring.io/blog/2013/11/01/exception-handling-in-spring-mvc
After that if you still get following page you can override org.springframework.boot.autoconfigure.web.ErrorController. There are an example: BasicErrorController. But this works only if you use spring boot application with embedded container. For example, if you will create war file form spring boot project and will deploy under tomcat, you will get standard tomcat error page.
So this mean that ErrorController is not common solution.
In my case i throws exceptions inside filters, that why /error page shown. So solution will be write own filter that converts exceptions to JSON representation. This solution should work for every container/server, and you can get more information about exception.

Resources