Spring Boot (1.3.5) - Default Error View - java

I'm using Spring Boot (v1.3.5.RELEASE). And in the docs, there's this short section regarding error-handling:
Spring Boot provides an /error mapping by default that handles all errors in a sensible way, and it is registered as a ‘global’ error page in the servlet container. For machine clients it will produce a JSON response with details of the error, the HTTP status and the exception message. For browser clients there is a ‘whitelabel’ error view that renders the same data in HTML format (to customize it just add a View that resolves to ‘error’).
So, to set my own custom page, I'd just need a view that resolves to error. I've added Freemarker to my classpath:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
And sure enough, making a file named error.ftl in src/main/resources/templates did the job of getting me my own custom page.
However, instead of having error.ftl in the resources/templates folder, I'd like to place it inside WEB-INF/templates.
So, I moved the file (now in WEB-INF/templates/error.ftl) and made the following spring configuration-related beans:
#Bean(name = "freeMarkerViewResolver")
public FreeMarkerViewResolver getFreeMarkerViewResolver() {
FreeMarkerViewResolver freeMarkerViewResolver = new FreeMarkerViewResolver();
freeMarkerViewResolver.setSuffix(".ftl");
return freeMarkerViewResolver;
}
#Bean(name = "freemarkerConfigurer")
public FreeMarkerConfigurer getFreeMarkerConfigurer() {
FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer();
freeMarkerConfigurer.setTemplateLoaderPaths(
"classpath:/templates/",
"/WEB-INF/templates/");
return freeMarkerConfigurer;
}
But now, I only get the whitelabel page instead of /WEB-INF/templates/error.ftl (when, let's say for example, I access an invalid path such as localhost:8080/invalid). Is there anything I missed?
I'm pretty sure BasicErrorController handles the job:
#RequestMapping(produces = "text/html")
public ModelAndView errorHtml(HttpServletRequest request,
HttpServletResponse response) {
response.setStatus(getStatus(request).value());
Map<String, Object> model = getErrorAttributes(request,
isIncludeStackTrace(request, MediaType.TEXT_HTML));
return new ModelAndView("error", model);
}
And here are my logs:
2016-09-12 08:46:00.241 TRACE 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Bound request context to thread: org.apache.catalina.connector.RequestFacade#11e1fd30
2016-09-12 08:46:00.241 DEBUG 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/invalid]
2016-09-12 08:46:00.242 TRACE 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Testing handler map [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#75739a6e] in DispatcherServlet with name 'dispatcherServlet'
2016-09-12 08:46:00.242 TRACE 5888 --- [nio-8080-exec-4] o.s.w.s.handler.SimpleUrlHandlerMapping : No handler mapping found for [/invalid]
2016-09-12 08:46:00.242 TRACE 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Testing handler map [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#67eec602] in DispatcherServlet with name 'dispatcherServlet'
2016-09-12 08:46:00.242 DEBUG 5888 --- [nio-8080-exec-4] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /invalid
2016-09-12 08:46:00.243 DEBUG 5888 --- [nio-8080-exec-4] s.w.s.m.m.a.RequestMappingHandlerMapping : Did not find handler method for [/invalid]
2016-09-12 08:46:00.244 TRACE 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Testing handler map [org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping#605d8da4] in DispatcherServlet with name 'dispatcherServlet'
2016-09-12 08:46:00.244 TRACE 5888 --- [nio-8080-exec-4] o.s.w.s.h.BeanNameUrlHandlerMapping : No handler mapping found for [/invalid]
2016-09-12 08:46:00.244 TRACE 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Testing handler map [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#3fa90efa] in DispatcherServlet with name 'dispatcherServlet'
2016-09-12 08:46:00.244 DEBUG 5888 --- [nio-8080-exec-4] o.s.w.s.handler.SimpleUrlHandlerMapping : Matching patterns for request [/invalid] are [/**]
2016-09-12 08:46:00.244 DEBUG 5888 --- [nio-8080-exec-4] o.s.w.s.handler.SimpleUrlHandlerMapping : URI Template variables for request [/invalid] are {}
2016-09-12 08:46:00.244 DEBUG 5888 --- [nio-8080-exec-4] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapping [/invalid] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/], class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver#16545fd3]]] and 1 interceptor
2016-09-12 08:46:00.244 TRACE 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Testing handler adapter [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#5ef1fb8a]
2016-09-12 08:46:00.244 TRACE 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Testing handler adapter [org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter#781974d0]
2016-09-12 08:46:00.244 DEBUG 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Last-Modified value for [/invalid] is: -1
2016-09-12 08:46:00.244 TRACE 5888 --- [nio-8080-exec-4] o.s.w.s.r.ResourceHttpRequestHandler : Applying "invalid path" checks to path: invalid
2016-09-12 08:46:00.244 TRACE 5888 --- [nio-8080-exec-4] o.s.w.s.resource.PathResourceResolver : Resolving resource for request path "invalid"
2016-09-12 08:46:00.244 TRACE 5888 --- [nio-8080-exec-4] o.s.w.s.resource.PathResourceResolver : Checking location: ServletContext resource [/]
2016-09-12 08:46:00.244 TRACE 5888 --- [nio-8080-exec-4] o.s.w.s.resource.PathResourceResolver : No match for location: ServletContext resource [/]
2016-09-12 08:46:00.244 TRACE 5888 --- [nio-8080-exec-4] o.s.w.s.resource.PathResourceResolver : Checking location: class path resource [META-INF/resources/]
2016-09-12 08:46:00.245 TRACE 5888 --- [nio-8080-exec-4] o.s.w.s.resource.PathResourceResolver : No match for location: class path resource [META-INF/resources/]
2016-09-12 08:46:00.245 TRACE 5888 --- [nio-8080-exec-4] o.s.w.s.resource.PathResourceResolver : Checking location: class path resource [resources/]
2016-09-12 08:46:00.245 TRACE 5888 --- [nio-8080-exec-4] o.s.w.s.resource.PathResourceResolver : No match for location: class path resource [resources/]
2016-09-12 08:46:00.245 TRACE 5888 --- [nio-8080-exec-4] o.s.w.s.resource.PathResourceResolver : Checking location: class path resource [static/]
2016-09-12 08:46:00.245 TRACE 5888 --- [nio-8080-exec-4] o.s.w.s.resource.PathResourceResolver : No match for location: class path resource [static/]
2016-09-12 08:46:00.245 TRACE 5888 --- [nio-8080-exec-4] o.s.w.s.resource.PathResourceResolver : Checking location: class path resource [public/]
2016-09-12 08:46:00.245 TRACE 5888 --- [nio-8080-exec-4] o.s.w.s.resource.PathResourceResolver : No match for location: class path resource [public/]
2016-09-12 08:46:00.245 TRACE 5888 --- [nio-8080-exec-4] o.s.w.s.r.ResourceHttpRequestHandler : No matching resource found - returning 404
2016-09-12 08:46:00.245 DEBUG 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2016-09-12 08:46:00.246 TRACE 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade#11e1fd30
2016-09-12 08:46:00.246 DEBUG 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Successfully completed request
2016-09-12 08:46:00.246 TRACE 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Bound request context to thread: org.apache.catalina.core.ApplicationHttpRequest#292356a6
2016-09-12 08:46:00.246 DEBUG 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/error]
2016-09-12 08:46:00.246 TRACE 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Testing handler map [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#75739a6e] in DispatcherServlet with name 'dispatcherServlet'
2016-09-12 08:46:00.246 TRACE 5888 --- [nio-8080-exec-4] o.s.w.s.handler.SimpleUrlHandlerMapping : No handler mapping found for [/error]
2016-09-12 08:46:00.246 TRACE 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Testing handler map [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#67eec602] in DispatcherServlet with name 'dispatcherServlet'
2016-09-12 08:46:00.246 DEBUG 5888 --- [nio-8080-exec-4] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /error
2016-09-12 08:46:00.247 TRACE 5888 --- [nio-8080-exec-4] s.w.s.m.m.a.RequestMappingHandlerMapping : Found 2 matching mapping(s) for [/error] : [{[/error],produces=[text/html]}, {[/error]}]
2016-09-12 08:46:00.248 DEBUG 5888 --- [nio-8080-exec-4] s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler method [public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)]
2016-09-12 08:46:00.248 TRACE 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Testing handler adapter [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#5ef1fb8a]
2016-09-12 08:46:00.248 DEBUG 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Last-Modified value for [/error] is: -1
2016-09-12 08:46:00.248 TRACE 5888 --- [nio-8080-exec-4] .w.s.m.m.a.ServletInvocableHandlerMethod : Invoking [BasicErrorController.errorHtml] method with arguments [org.apache.catalina.core.ApplicationHttpRequest#292356a6, org.apache.catalina.connector.ResponseFacade#4fa94295]
2016-09-12 08:46:00.248 TRACE 5888 --- [nio-8080-exec-4] .w.s.m.m.a.ServletInvocableHandlerMethod : Method [errorHtml] returned [ModelAndView: reference to view with name 'error'; model is {timestamp=Mon Sep 12 08:46:00 SGT 2016, status=404, error=Not Found, message=No message available, path=/invalid}]
2016-09-12 08:46:00.249 DEBUG 5888 --- [nio-8080-exec-4] o.s.w.s.v.ContentNegotiatingViewResolver : Requested media types are [text/html, text/html;q=0.8] based on Accept header types and producible media types [text/html])
2016-09-12 08:46:00.249 DEBUG 5888 --- [nio-8080-exec-4] o.s.w.s.v.ContentNegotiatingViewResolver : Returning [org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$SpelView#58edc30] based on requested media type 'text/html'
2016-09-12 08:46:00.249 DEBUG 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Rendering view [org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$SpelView#58edc30] in DispatcherServlet with name 'dispatcherServlet'
2016-09-12 08:46:00.249 TRACE 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Cleared thread-bound request context: org.apache.catalina.core.ApplicationHttpRequest#292356a6
2016-09-12 08:46:00.249 DEBUG 5888 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Successfully completed request

Instead of redefining the freemarker beans (which may be the cause of your error), you could use spring-boot's property spring.freemarker.template-loader-path, as described here:
If you use FreeMarker you will also have a FreeMarkerViewResolver with
id ‘freeMarkerViewResolver’. It looks for resources in a loader path
(externalized to spring.freemarker.templateLoaderPath, default
‘classpath:/templates/’) by surrounding the view name with a prefix
and suffix (externalized to spring.freemarker.prefix and
spring.freemarker.suffix, with empty and ‘.ftl’ defaults
respectively). It can be overridden by providing a bean of the same
name.
The default is this:
spring.freemarker.template-loader-path=classpath:/templates/ # Comma-separated list of template paths.
You could add this to your application.properties:
spring.freemarker.template-loader-path=classpath:/WEB-INF/templates/

Related

Cannot open swagger-ui with the usage of Openapi in Spring Boot 3 (Whitelabel Error Page)

I have an issue to open swagger-ui through Openapi in Spring Boot.
When I try to open this URL http://localhost:8080/swagger-ui.html, I get Whitelabel Error Page
How can I fix the issue?
Here is the dependency defined in pom.xml shown below.
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.4</version>
</dependency>
Here is the openpi config class shown below.
#Configuration
public class OpenApiConfig {
#Bean
public OpenAPI customOpenAPI(#Value("${application-description}") String description,
#Value("${application-version}") String version) {
return new OpenAPI()
.info(new Info().title("API")
.version(version)
.description(description)
.license(new License().name("API Licence")));
}
}
Here is the application.properties file shown below.
springdoc.swagger-ui.path=/swagger-ui.html
application-description=API Description
application-version=1.0
logging.level.org.springframework.web=DEBUG
logging.level.io.springfox=DEBUG
Here is the error shown below when I try to open this URL http://localhost:8080/swagger-ui.html
2023-02-09T08:36:16.593+03:00 DEBUG 20184 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : GET "/swagger-ui.html", parameters={}
2023-02-09T08:36:16.594+03:00 DEBUG 20184 --- [nio-8080-exec-4] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]
2023-02-09T08:36:16.596+03:00 DEBUG 20184 --- [nio-8080-exec-4] o.s.w.s.r.ResourceHttpRequestHandler : Resource not found
2023-02-09T08:36:16.596+03:00 DEBUG 20184 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Completed 404 NOT_FOUND
2023-02-09T08:36:16.597+03:00 DEBUG 20184 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : "ERROR" dispatch for GET "/error", parameters={}
2023-02-09T08:36:16.597+03:00 DEBUG 20184 --- [nio-8080-exec-4] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#errorHtml(HttpServletRequest, HttpServletResponse)
2023-02-09T08:36:16.599+03:00 DEBUG 20184 --- [nio-8080-exec-4] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, text/html;q=0.8]
2023-02-09T08:36:16.599+03:00 DEBUG 20184 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Exiting from "ERROR" dispatch, status 404
How can I fix the issue?
Here is the repo : Link
You need to use a different dependency for Spring Boot 3:
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.0.2</version>
</dependency>

Request method 'PATCH' not supported

I have a profile update page which is supposed to show errors on the fields.
However, when I remove the value from an input field instead of getting an error below, I get 405 - Request method 'PATCH' not supported.
I have no idea what could be the problem, any advice is appreciated.
#Controller
#RequestMapping("/users")
public class UserController {
#GetMapping("/profile/update/{id}")
public String showUpdateForm(#PathVariable("id") Long id, Model model) {
ProfileUpdateServiceModel profileServiceModel = this.userService.getProfileUpdateServiceModelById(id);
ProfileUpdateBindingModel profileUpdateBindingModel = this.mapper.map(profileServiceModel, ProfileUpdateBindingModel.class);
if (!model.containsAttribute("profileUpdateBindingModel")) {
model.addAttribute("profileUpdateBindingModel", profileUpdateBindingModel);
}
// model.addAttribute("profileUpdateBindingModel", profileUpdateBindingModel);
return "update-profile";
}
#PatchMapping("/profile/update/{id}")
public String update(#PathVariable("id") Long id,
#Valid ProfileUpdateBindingModel profileUpdateBindingModel,
BindingResult br,
RedirectAttributes rAtt) {
if (br.hasErrors()) {
rAtt
.addFlashAttribute("profileUpdateBindingModel", profileUpdateBindingModel)
.addFlashAttribute("org.springframework.validation.BindingResult.profileUpdateBindingModel", br);
return "redirect:/users/profile/update/" + id;
}
return "profile";
}
profile.html:
<form
th:method="GET"
th:action="#{/users/profile/update/{id}(id=${session.currentUserId})}">
update-profile.html:
<form
th:action="#{/users/profile/update/{id}(id=*{userId})}"
th:method="PATCH"
th:object="${profileUpdateBindingModel}"
enctype="multipart/form-data">
<div class="col-sm-6">
<label class="label-align">First Name<span
class="required">*</span></label>
<input
th:field="*{firstName}"
type="text"
class="form-control"
name="name"/>
<div class="col-auto">
<small th:if="${#fields.hasErrors('firstName')}"
th:errors="*{firstName}"
id="first-nameError"
class="text-light form-text bg-danger rounded">xxx</small>
</div>
</div>
LOGS:
2022-03-06 11:57:45.050 DEBUG 9492 --- [nio-8080-exec-6] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, application/xhtml+xml, image/avif, image/webp, image/apng, application/xml;q=0.9, application/signed-exchange;v=b3;q=0.9, */*;q=0.8]
2022-03-06 11:57:45.077 DEBUG 9492 --- [nio-8080-exec-6] o.s.web.servlet.DispatcherServlet : Completed 200 OK
2022-03-06 11:57:45.131 DEBUG 9492 --- [nio-8080-exec-7] o.s.web.servlet.DispatcherServlet : GET "/css/style.css", parameters={}
2022-03-06 11:57:45.131 DEBUG 9492 --- [nio-8080-exec-7] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped to ResourceHttpRequestHandler [classpath [static/], ServletContext [/]]
2022-03-06 11:57:45.135 DEBUG 9492 --- [nio-8080-exec-7] o.s.web.servlet.DispatcherServlet : Completed 200 OK
2022-03-06 11:57:45.138 DEBUG 9492 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet : GET "/images/undraw_profile_1.svg", parameters={}
2022-03-06 11:57:45.138 DEBUG 9492 --- [nio-8080-exec-3] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped to ResourceHttpRequestHandler [classpath [static/], ServletContext [/]]
2022-03-06 11:57:45.138 DEBUG 9492 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet : Completed 200 OK
2022-03-06 11:57:45.168 DEBUG 9492 --- [nio-8080-exec-9] o.s.web.servlet.DispatcherServlet : GET "/images/1915.jpg", parameters={}
2022-03-06 11:57:45.169 DEBUG 9492 --- [nio-8080-exec-9] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped to ResourceHttpRequestHandler [classpath [static/], ServletContext [/]]
2022-03-06 11:57:45.178 DEBUG 9492 --- [nio-8080-exec-9] o.s.web.servlet.DispatcherServlet : Completed 200 OK
2022-03-06 11:57:59.981 DEBUG 9492 --- [nio-8080-exec-6] o.s.web.servlet.DispatcherServlet : PATCH "/users/profile/update/", parameters={multipart}
2022-03-06 11:57:59.984 WARN 9492 --- [nio-8080-exec-6] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'PATCH' not supported]
2022-03-06 11:57:59.984 DEBUG 9492 --- [nio-8080-exec-6] o.s.web.servlet.DispatcherServlet : Completed 405 METHOD_NOT_ALLOWED
2022-03-06 11:57:59.986 DEBUG 9492 --- [nio-8080-exec-6] o.s.web.servlet.DispatcherServlet : "ERROR" dispatch for POST "/error", parameters={multipart}
2022-03-06 11:57:59.986 DEBUG 9492 --- [nio-8080-exec-6] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#errorHtml(HttpServletRequest, HttpServletResponse)
2022-03-06 11:57:59.995 DEBUG 9492 --- [nio-8080-exec-6] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, text/html;q=0.8]
2022-03-06 11:58:00.022 DEBUG 9492 --- [nio-8080-exec-6] o.s.web.servlet.DispatcherServlet : Exiting from "ERROR" dispatch, status 405
2022-03-06 11:58:00.077 DEBUG 9492 --- [nio-8080-exec-7] o.s.web.servlet.DispatcherServlet : GET "/css/style.css", parameters={}
2022-03-06 11:58:00.078 DEBUG 9492 --- [nio-8080-exec-7] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped to ResourceHttpRequestHandler [classpath [static/], ServletContext [/]]
2022-03-06 11:58:00.083 DEBUG 9492 --- [nio-8080-exec-7] o.s.web.servlet.DispatcherServlet : Completed 200 OK
2022-03-06 11:58:00.132 DEBUG 9492 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet : GET "/images/undraw_profile_1.svg", parameters={}
2022-03-06 11:58:00.134 DEBUG 9492 --- [nio-8080-exec-3] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped to ResourceHttpRequestHandler [classpath [static/], ServletContext [/]]
2022-03-06 11:58:00.137 DEBUG 9492 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet : Completed 200 OK
HTTP Code 405 means Method not Allowed. In your spring you are mentioning GET method but in your Form you are mentioning to submit a PATCH method.
Change your form to
<form
th:action="#{/users/profile/update/{id}(id=*{userId})}"
th:method="GET"
th:object="${profileUpdateBindingModel}"
enctype="multipart/form-data">
I'd use the pathvariable like this :
#PathVariable Long id
or like this ::
#PatchMapping(params = "/{id}", consumes = "application/json")
I am not confident about thymeleaf, but you can check this syntax[in second html page]:
th:action="#{/users/profile/update/{id}(id=*{userId})}"
As in your home.html form, you have assigned the value using $ sign but here it is in *.
Also, make sure your forms are enclosed properly with </form> tags.

I am running my application which is based java spring boot framework. but getting this error. Can you help me to resolve this error?

I am running my application which is based java spring boot framework. basically i have more then one microservices and I want them to communicate using http rest .
but getting this error. Can you help me to resolve this error??
2022-01-10 10:31:52.834 INFO 13740 --- [ main] com.accounts.account.AccountApplication : Started AccountApplication in 53.129 seconds (JVM running for 57.978)
2022-01-10 10:31:53.259 DEBUG 13740 --- [ main] o.s.b.a.ApplicationAvailabilityBean : Application availability state LivenessState changed to CORRECT
2022-01-10 10:31:53.274 DEBUG 13740 --- [ main] o.s.b.a.ApplicationAvailabilityBean : Application availability state ReadinessState changed to ACCEPTING_TRAFFIC
2022-01-10 10:32:42.838 INFO 13740 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-01-10 10:32:42.838 INFO 13740 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2022-01-10 10:32:42.839 DEBUG 13740 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Detected StandardServletMultipartResolver
2022-01-10 10:32:42.840 DEBUG 13740 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Detected AcceptHeaderLocaleResolver
2022-01-10 10:32:42.841 DEBUG 13740 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Detected FixedThemeResolver
2022-01-10 10:32:42.848 DEBUG 13740 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Detected org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator#72a61e61
2022-01-10 10:32:42.850 DEBUG 13740 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Detected org.springframework.web.servlet.support.SessionFlashMapManager#742dbac8
2022-01-10 10:32:42.851 DEBUG 13740 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : enableLoggingRequestDetails='false': request parameters and headers will be masked to prevent unsafe logging of potentially sensitive data
2022-01-10 10:32:42.852 INFO 13740 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 13 ms
2022-01-10 10:32:42.942 DEBUG 13740 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : GET "/", parameters={}
2022-01-10 10:32:43.030 DEBUG 13740 --- [nio-8080-exec-1] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]
2022-01-10 10:32:43.046 DEBUG 13740 --- [nio-8080-exec-1] o.j.s.OpenEntityManagerInViewInterceptor : Opening JPA EntityManager in OpenEntityManagerInViewInterceptor
2022-01-10 10:32:43.069 DEBUG 13740 --- [nio-8080-exec-1] o.s.w.s.r.ResourceHttpRequestHandler : Resource not found
2022-01-10 10:32:43.071 DEBUG 13740 --- [nio-8080-exec-1] o.j.s.OpenEntityManagerInViewInterceptor : Closing JPA EntityManager in OpenEntityManagerInViewInterceptor
2022-01-10 10:32:43.072 DEBUG 13740 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed 404 NOT_FOUND
2022-01-10 10:32:43.144 DEBUG 13740 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : "ERROR" dispatch for GET "/error", parameters={}
2022-01-10 10:32:43.229 DEBUG 13740 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#errorHtml(HttpServletRequest, HttpServletResponse)
2022-01-10 10:32:43.231 DEBUG 13740 --- [nio-8080-exec-1] o.j.s.OpenEntityManagerInViewInterceptor : Opening JPA EntityManager in OpenEntityManagerInViewInterceptor
2022-01-10 10:32:43.750 DEBUG 13740 --- [nio-8080-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, text/html;q=0.8]
2022-01-10 10:32:43.790 DEBUG 13740 --- [nio-8080-exec-1] o.j.s.OpenEntityManagerInViewInterceptor : Closing JPA EntityManager in OpenEntityManagerInViewInterceptor
2022-01-10 10:32:43.791 DEBUG 13740 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Exiting from "ERROR" dispatch, status 404
From the code, it seems you are trying to retrieve an account based on the customer id. In that case, it will be #GetMapping and not #PostMapping ( at line 12). Also , in case of get, we pass the variables in the url and not in the request body.
As a coding practice, the className should start with a capital letter ( the return type of your method should be Account and not accounts )
#GetMapping("/myAccount/{id}
public Account AccountsGetAccountDetails(#PathVariable String id ) {}

What's the correct directory structure of SpringBoot project that uses static conten

I am triying to understand why my SpringBoot webApp doesn't render in the browser. This is what my debug log says:
2017-08-04 14:54:24.760 DEBUG 23863 --- [tp1027569178-15] o.s.w.servlet.view.InternalResourceView : Forwarding to resource [/views/tictactoe.html] in InternalResourceView 'tictactoe'
2017-08-04 14:54:24.762 DEBUG 23863 --- [tp1027569178-15] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/views/tictactoe.html]
2017-08-04 14:54:24.766 DEBUG 23863 --- [tp1027569178-15] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /views/tictactoe.html
2017-08-04 14:54:24.768 DEBUG 23863 --- [tp1027569178-15] s.w.s.m.m.a.RequestMappingHandlerMapping : Did not find handler method for [/views/tictactoe.html]
2017-08-04 14:54:24.768 DEBUG 23863 --- [tp1027569178-15] o.s.w.s.handler.SimpleUrlHandlerMapping : Matching patterns for request [/views/tictactoe.html] are [/**]
2017-08-04 14:54:24.770 DEBUG 23863 --- [tp1027569178-15] o.s.w.s.handler.SimpleUrlHandlerMapping : URI Template variables for request [/views/tictactoe.html] are {}
2017-08-04 14:54:24.771 DEBUG 23863 --- [tp1027569178-15] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapping [/views/tictactoe.html] to HandlerExecutionChain with handler [org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler#47b52f9] and 1 interceptor
2017-08-04 14:54:24.771 DEBUG 23863 --- [tp1027569178-15] o.s.web.servlet.DispatcherServlet : Last-Modified value for [/views/tictactoe.html] is: -1
2017-08-04 14:54:24.772 DEBUG 23863 --- [tp1027569178-15] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/error]
2017-08-04 14:54:24.777 DEBUG 23863 --- [tp1027569178-15] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /error
2017-08-04 14:54:24.778 DEBUG 23863 --- [tp1027569178-15] s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler method [public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)]
2017-08-04 14:54:24.778 DEBUG 23863 --- [tp1027569178-15] o.s.web.servlet.DispatcherServlet : Last-Modified value for [/error] is: -1
2017-08-04 14:54:24.784 DEBUG 23863 --- [tp1027569178-15] o.s.web.servlet.DispatcherServlet : Rendering view [org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$SpelView#41ee3720] in DispatcherServlet with name 'dispatcherServlet'
2017-08-04 14:54:24.795 DEBUG 23863 --- [tp1027569178-15] o.s.web.servlet.DispatcherServlet : Successfully completed request
2017-08-04 14:54:24.802 DEBUG 23863 --- [tp1027569178-15] o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2017-08-04 14:54:24.802 DEBUG 23863 --- [tp1027569178-15] o.s.web.servlet.DispatcherServlet : Successfully completed request
2017-08-04 14:54:24.804 DEBUG 23863 --- [tp1027569178-15] o.s.web.servlet.DispatcherServlet : Successfully completed request
I am not sure if my directory structure its correct. This is how it looks like:
enter code here
Maybe something wrong in my web page/angular?
<!DOCTYPE html>
<html ng-app="myApp" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
<title>TicTacToe</title>
<link type="text/css" href="css/design.css" rel="stylesheet" />
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js"></script>
<script src="js/tictactoe.js"></script>
</head>
<body ng-controller="displayPageController">
<div id="player-1">PLAYER 1<br/>
{{gameBoardDto.player1}}<span style="display:inline-block"/>
</div>
<div id="game">
<div id="top-left" ng-click='playPage("topleft")'>{{gameBoardDto.topleft}}<span style="display:inline-block"/></div>
<div id="top" ng-click='playPage("top")'>{{gameBoardDto.top}}<span style="display:inline-block"/></div>
<div id="top-right" ng-click='playPage("topright")'>{{gameBoardDto.topright}}<span style="display:inline-block"/></div>
<div id="left" ng-click='playPage("left")'>{{gameBoardDto.left}}<span style="display:inline-block"/></div>
<div id="middle" ng-click='playPage("middle")'>{{gameBoardDto.middle}}<span style="display:inline-block"/></div>
<div id="right" ng-click='playPage("right")'>{{gameBoardDto.right}}<span style="display:inline-block"/></div>
<div id="bottom-left" ng-click='playPage("bottomleft")'>{{gameBoardDto.bottomleft}}<span style="display:inline-block"/></div>
<div id="bottom" ng-click='playPage("bottom")'>{{gameBoardDto.bottom}}<span style="display:inline-block"/></div>
<div id="bottom-right" ng-click='playPage("bottomright")'>{{gameBoardDto.bottomright}}<span style="display:inline-block"/></div>
</div>
<div id="player-2">PLAYER 2<br/>
{{gameBoardDto.player2}}<span style="display:inline-block"/>
</div>
</body>
</html>
This is my Spring MVC conf:
package application;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
#Configuration
#EnableWebMvc
public class MvcConfiguration extends WebMvcConfigurerAdapter {
//This allows html pages to be resolved
#Bean
public ViewResolver getViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/views/");
resolver.setSuffix(".html");
return resolver;
}
/*
This allows resources such as .js .css etc to be resolved
Here an example of how the views are linked to the resources
<link rel="stylesheet" type="text/css" href="resources/css/design.css"/>
*/
#Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
}
#Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
}
Any idea how can I fix this issue? My browser just renders an error when I try to access:
update
I did as Andy Wilkinson suggested but didn't really work but I did some modifications and now I have the page being served but the javascript not working.
This is what I did:
- I deleted the #EnableWebMvc from MvcConfiguration
- Removed addResourceHandlers and configureDefaultServletHandling from MvcConfiguration
- Removed ViewResolver #Bean method from MvcConfiguration
- I added a dependency to compile group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf'
- I created a directory called templates and I moved the .html files there
Now the browser shows me this:
[![enter code here][3]][3]
This is what the log outputs:
017-08-06 13:58:54.397 DEBUG 17581 --- [qtp758944736-18] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/error]
2017-08-06 13:58:54.402 DEBUG 17581 --- [qtp758944736-19] o.s.web.servlet.DispatcherServlet : Last-Modified value for [/error] is: -1
2017-08-06 13:58:54.402 DEBUG 17581 --- [qtp758944736-18] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /error
2017-08-06 13:58:54.403 DEBUG 17581 --- [qtp758944736-18] s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler method [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)]
2017-08-06 13:58:54.403 DEBUG 17581 --- [qtp758944736-18] o.s.web.servlet.DispatcherServlet : Last-Modified value for [/error] is: -1
2017-08-06 13:58:54.508 DEBUG 17581 --- [qtp758944736-18] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Written [{timestamp=Sun Aug 06 13:58:54 BST 2017, status=404, error=Not Found, message=Not Found, path=/resources/css/design.css}] as "application/json;charset=UTF-8" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter#15adc6be]
2017-08-06 13:58:54.508 DEBUG 17581 --- [qtp758944736-18] o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2017-08-06 13:58:54.508 DEBUG 17581 --- [qtp758944736-18] o.s.web.servlet.DispatcherServlet : Successfully completed request
2017-08-06 13:58:54.509 DEBUG 17581 --- [qtp758944736-18] o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2017-08-06 13:58:54.509 DEBUG 17581 --- [qtp758944736-18] o.s.web.servlet.DispatcherServlet : Successfully completed request
2017-08-06 13:58:54.510 DEBUG 17581 --- [qtp758944736-19] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Written [{timestamp=Sun Aug 06 13:58:54 BST 2017, status=404, error=Not Found, message=Not Found, path=/resources/javascript/tictactoe.js}] as "application/json;charset=UTF-8" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter#15adc6be]
2017-08-06 13:58:54.511 DEBUG 17581 --- [qtp758944736-19] o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2017-08-06 13:58:54.511 DEBUG 17581 --- [qtp758944736-19] o.s.web.servlet.DispatcherServlet : Successfully completed request
2017-08-06 13:58:54.511 DEBUG 17581 --- [qtp758944736-19] o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2017-08-06 13:58:54.511 DEBUG 17581 --- [qtp758944736-19] o.s.web.servlet.DispatcherServlet : Successfully completed request
2017-08-06 13:58:54.700 DEBUG 17581 --- [qtp758944736-21] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/resources/javascript/tictactoe.js]
2017-08-06 13:58:54.701 DEBUG 17581 --- [qtp758944736-21] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /resources/javascript/tictactoe.js
2017-08-06 13:58:54.701 DEBUG 17581 --- [qtp758944736-21] s.w.s.m.m.a.RequestMappingHandlerMapping : Did not find handler method for [/resources/javascript/tictactoe.js]
2017-08-06 13:58:54.701 DEBUG 17581 --- [qtp758944736-21] o.s.w.s.handler.SimpleUrlHandlerMapping : Matching patterns for request [/resources/javascript/tictactoe.js] are [/**]
2017-08-06 13:58:54.701 DEBUG 17581 --- [qtp758944736-21] o.s.w.s.handler.SimpleUrlHandlerMapping : URI Template variables for request [/resources/javascript/tictactoe.js] are {}
2017-08-06 13:58:54.701 DEBUG 17581 --- [qtp758944736-21] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapping [/resources/javascript/tictactoe.js] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/], class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver#453002f1]]] and 1 interceptor
2017-08-06 13:58:54.701 DEBUG 17581 --- [qtp758944736-21] o.s.web.servlet.DispatcherServlet : Last-Modified value for [/resources/javascript/tictactoe.js] is: -1
2017-08-06 13:58:54.702 DEBUG 17581 --- [qtp758944736-21] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/error]
2017-08-06 13:58:54.703 DEBUG 17581 --- [qtp758944736-21] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /error
2017-08-06 13:58:54.704 DEBUG 17581 --- [qtp758944736-21] s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler method [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)]
2017-08-06 13:58:54.704 DEBUG 17581 --- [qtp758944736-21] o.s.web.servlet.DispatcherServlet : Last-Modified value for [/error] is: -1
2017-08-06 13:58:54.711 DEBUG 17581 --- [qtp758944736-21] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Written [{timestamp=Sun Aug 06 13:58:54 BST 2017, status=404, error=Not Found, message=Not Found, path=/resources/javascript/tictactoe.js}] as "application/json;charset=UTF-8" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter#15adc6be]
2017-08-06 13:58:54.711 DEBUG 17581 --- [qtp758944736-21] o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2017-08-06 13:58:54.711 DEBUG 17581 --- [qtp758944736-21] o.s.web.servlet.DispatcherServlet : Successfully completed request
2017-08-06 13:58:54.711 DEBUG 17581 --- [qtp758944736-21] o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2017-08-06 13:58:54.711 DEBUG 17581 --- [qtp758944736-21] o.s.web.servlet.DispatcherServlet : Successfully completed request
This is the project if somebody wants to have a look:
https://github.com/SFRJ/tictactoe(Note: The version in github works when running with gradlew but not running from the .jar)
#EnableWebMvc switches off Spring Boot's auto-configuration of Spring MVC. That includes configuring it to serve static resources from classpath:static/ (which is where you resources in src/main/resources/static will end up. You also have a few other bits of configuration that Spring Boot will configure for you.
This should get you up an running:
Remove #EnableWebMvc from MvcConfiguration
Remove your overrides of addResourceHandlers and configureDefaultServletHandling from MvcConfiguration
Remove your ViewResolver #Bean method from MvcConfiguration
Assuming that its contents are the HTML in your question, move tictactoe.html into src/main/resources/static
Try moving the static folder to the project root, where it will be a sibling of src. Tomcat will then serve the contents using the default Servlet.

Spring Social fails to connect with facebook

I am using quite basic setting to connect facebook using spring boot and spring social, but I am getting a warning in the log and no other details:
2015-11-01 09:26:34.574 WARN 69742 --- [nio-8181-exec-1] o.s.s.connect.web.ConnectController : Exception while handling OAuth2 callback ((#3) Application does not have the capability to make this API call.). Redirecting to facebook connection status page.
My controller:
#Controller
public class UserLoginOauth {
private Facebook facebook;
#Inject
public UserLoginOauth(Facebook facebook) {
this.facebook = facebook;
}
#RequestMapping(value = "/fb")
public String connectFacebook(Model model) {
try {
if (!facebook.isAuthorized()) {
return "redirect:/connect/facebook";
}
} catch (Exception e) {
return "redirect:/connect/facebook";
}
return null;
}
and my property file:
spring.social.facebook.appId=XXX
spring.social.facebook.appSecret=YYY
spring.social.auto_connection_views=true
When I go to my /fb url, I am redirect to http://localhost:8181/connect/facebook with a button to connect to facebook
On clicking that button, it calls http://localhost:8181/connect/facebook and then redirect to https://www.facebook.com/v2.3/dialog/oauth?client_id=WWW and again it redirects to http://localhost:8181/connect/facebook?code=ddd&state=GGG
But this redirect fails with the warning message "Exception while handling OAuth2 callback", with no other information.
I enabled spring social logs, and put it below incase it helps!
2015-11-09 15:07:38.130 DEBUG 14198 --- [nio-8181-exec-3] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing POST request for [/connect/facebook]
2015-11-09 15:07:38.131 DEBUG 14198 --- [nio-8181-exec-3] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /connect/facebook
2015-11-09 15:07:38.131 DEBUG 14198 --- [nio-8181-exec-3] s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler method [public org.springframework.web.servlet.view.RedirectView org.springframework.social.connect.web.ConnectController.connect(java.lang.String,org.springframework.web.context.request.NativeWebRequest)]
2015-11-09 15:07:38.131 DEBUG 14198 --- [nio-8181-exec-3] o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'connectController'
2015-11-09 15:07:38.131 DEBUG 14198 --- [nio-8181-exec-3] o.j.s.OpenEntityManagerInViewInterceptor : Opening JPA EntityManager in OpenEntityManagerInViewInterceptor
2015-11-09 15:07:38.132 DEBUG 14198 --- [nio-8181-exec-3] o.s.web.servlet.DispatcherServlet : Rendering view [org.springframework.web.servlet.view.RedirectView: unnamed; URL [https://www.facebook.com/v2.3/dialog/oauth?client_id=XXX&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A8181%2Fconnect%2Ffacebook&state=SSS]] in DispatcherServlet with name 'dispatcherServlet'
2015-11-09 15:07:38.132 DEBUG 14198 --- [nio-8181-exec-3] o.j.s.OpenEntityManagerInViewInterceptor : Closing JPA EntityManager in OpenEntityManagerInViewInterceptor
2015-11-09 15:07:38.132 DEBUG 14198 --- [nio-8181-exec-3] o.s.orm.jpa.EntityManagerFactoryUtils : Closing JPA EntityManager
2015-11-09 15:07:38.132 DEBUG 14198 --- [nio-8181-exec-3] o.s.web.servlet.DispatcherServlet : Successfully completed request
2015-11-09 15:07:42.007 DEBUG 14198 --- [nio-8181-exec-4] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/connect/facebook]
2015-11-09 15:07:42.007 DEBUG 14198 --- [nio-8181-exec-4] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /connect/facebook
2015-11-09 15:07:42.008 DEBUG 14198 --- [nio-8181-exec-4] s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler method [public org.springframework.web.servlet.view.RedirectView org.springframework.social.connect.web.ConnectController.oauth2Callback(java.lang.String,org.springframework.web.context.request.NativeWebRequest)]
2015-11-09 15:07:42.008 DEBUG 14198 --- [nio-8181-exec-4] o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'connectController'
2015-11-09 15:07:42.008 DEBUG 14198 --- [nio-8181-exec-4] o.s.web.servlet.DispatcherServlet : Last-Modified value for [/connect/facebook] is: -1
2015-11-09 15:07:42.008 DEBUG 14198 --- [nio-8181-exec-4] o.j.s.OpenEntityManagerInViewInterceptor : Opening JPA EntityManager in OpenEntityManagerInViewInterceptor
2015-11-09 15:07:42.009 DEBUG 14198 --- [nio-8181-exec-4] o.s.web.client.RestTemplate : Created POST request for "https://graph.facebook.com/v2.3/oauth/access_token"
2015-11-09 15:07:42.009 DEBUG 14198 --- [nio-8181-exec-4] o.s.web.client.RestTemplate : Setting request Accept header to [application/x-www-form-urlencoded, multipart/form-data, application/json, application/*+json]
2015-11-09 15:07:42.009 DEBUG 14198 --- [nio-8181-exec-4] o.s.web.client.RestTemplate : Writing [{client_id=[AAA], client_secret=[BBB], code=[CCC], redirect_uri=[http://localhost:8181/connect/facebook], grant_type=[authorization_code]}] using [org.springframework.http.converter.FormHttpMessageConverter#16aa8eeb]
2015-11-09 15:07:42.554 DEBUG 14198 --- [nio-8181-exec-4] o.s.web.client.RestTemplate : POST request for "https://graph.facebook.com/v2.3/oauth/access_token" resulted in 200 (OK)
2015-11-09 15:07:42.555 DEBUG 14198 --- [nio-8181-exec-4] o.s.web.client.RestTemplate : Reading [interface java.util.Map] as "application/json;charset=UTF-8" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter#53ab366e]
2015-11-09 15:07:42.559 DEBUG 14198 --- [nio-8181-exec-4] o.s.web.client.RestTemplate : Created GET request for "https://graph.facebook.com/v2.3/me?fields=id%2Cabout%2Cage_range%2Caddress%2Cbio%2Cbirthday%2Ccontext%2Ccover%2Ccurrency%2Cdevices%2Ceducation%2Cemail%2Cfavorite_athletes%2Cfavorite_teams%2Cfirst_name%2Cgender%2Chometown%2Cinspirational_people%2Cinstalled%2Cinstall_type%2Cis_verified%2Clanguages%2Clast_name%2Clink%2Clocale%2Clocation%2Cmeeting_for%2Cmiddle_name%2Cname%2Cname_format%2Cpolitical%2Cquotes%2Cpayment_pricepoints%2Crelationship_status%2Creligion%2Csecurity_settings%2Csignificant_other%2Csports%2Ctest_group%2Ctimezone%2Cthird_party_id%2Cupdated_time%2Cverified%2Cvideo_upload_limits%2Cviewer_can_send_gift%2Cwebsite%2Cwork"
2015-11-09 15:07:42.584 DEBUG 14198 --- [nio-8181-exec-4] o.s.web.client.RestTemplate : Setting request Accept header to [application/json, application/*+json]
2015-11-09 15:07:42.695 DEBUG 14198 --- [nio-8181-exec-4] o.s.web.client.RestTemplate : GET request for "https://graph.facebook.com/v2.3/me?fields=id%2Cabout%2Cage_range%2Caddress%2Cbio%2Cbirthday%2Ccontext%2Ccover%2Ccurrency%2Cdevices%2Ceducation%2Cemail%2Cfavorite_athletes%2Cfavorite_teams%2Cfirst_name%2Cgender%2Chometown%2Cinspirational_people%2Cinstalled%2Cinstall_type%2Cis_verified%2Clanguages%2Clast_name%2Clink%2Clocale%2Clocation%2Cmeeting_for%2Cmiddle_name%2Cname%2Cname_format%2Cpolitical%2Cquotes%2Cpayment_pricepoints%2Crelationship_status%2Creligion%2Csecurity_settings%2Csignificant_other%2Csports%2Ctest_group%2Ctimezone%2Cthird_party_id%2Cupdated_time%2Cverified%2Cvideo_upload_limits%2Cviewer_can_send_gift%2Cwebsite%2Cwork" resulted in 400 (Bad Request); invoking error handler
2015-11-09 15:07:42.696 DEBUG 14198 --- [nio-8181-exec-4] o.s.s.f.api.impl.FacebookErrorHandler : Error from Facebook: {"error":{"message":"(#3) Application does not have the capability to make this API call.","type":"OAuthException","code":3,"fbtrace_id":"HB0Fe9k\/zM1"}}
2015-11-09 15:07:42.696 DEBUG 14198 --- [nio-8181-exec-4] o.s.s.f.api.impl.FacebookErrorHandler : Facebook error:
2015-11-09 15:07:42.696 DEBUG 14198 --- [nio-8181-exec-4] o.s.s.f.api.impl.FacebookErrorHandler : CODE : 3
2015-11-09 15:07:42.696 DEBUG 14198 --- [nio-8181-exec-4] o.s.s.f.api.impl.FacebookErrorHandler : TYPE : OAuthException
2015-11-09 15:07:42.696 DEBUG 14198 --- [nio-8181-exec-4] o.s.s.f.api.impl.FacebookErrorHandler : SUBCODE : null
2015-11-09 15:07:42.696 DEBUG 14198 --- [nio-8181-exec-4] o.s.s.f.api.impl.FacebookErrorHandler : MESSAGE : (#3) Application does not have the capability to make this API call.
2015-11-09 15:07:42.696 DEBUG 14198 --- [nio-8181-exec-4] o.s.s.f.api.impl.FacebookErrorHandler : USER TITLE : null
2015-11-09 15:07:42.719 DEBUG 14198 --- [nio-8181-exec-4] o.s.s.f.api.impl.FacebookErrorHandler : USER MESSAGE: null
2015-11-09 15:07:42.719 WARN 14198 --- [nio-8181-exec-4] o.s.s.connect.web.ConnectController : Exception while handling OAuth2 callback ((#3) Application does not have the capability to make this API call.). Redirecting to facebook connection status page.
2015-11-09 15:07:42.719 DEBUG 14198 --- [nio-8181-exec-4] o.s.web.servlet.DispatcherServlet : Rendering view [org.springframework.web.servlet.view.RedirectView: unnamed; URL [/connect/facebook]] in DispatcherServlet with name 'dispatcherServlet'
extend two of spring social class ConnectResource & ConnectSupport and
override the callback_url or aplicationUrl your problem will be
resolve

Categories

Resources