I am migrating springfox to spring doc and get 406 error.
Similar like this: https://github.com/springdoc/springdoc-openapi/issues/950
Only the swagger-ui got the issue but the /v3/api-docs can generate the json/yaml file.
After I debug the DispatcherServlet in doDispatch, an exception occur during getHandler.
The exception is:
org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation.
Below is the picture of the debug. If I debug further, the request /swagger-ui/index.html is actually mapped to an endpoint that accept /{param1}/{param2} that generates application/json. So, how to map the swagger path to the resource instead of a controller? Thank you
Spring boot version 1.5.x (spring 4.x). springdoc version 1.6.14.
Related
I am upgrading my jhipster application to the latest jhipster version which is 7.6.0.
Jhipster 7.6.0 introduces latest version of spring boot (2.6.3) and spring framework (5.3.15)
For security configuration class, I am still using the annotations from spring web mvc and I am not using spring web reactive. At this point, I dont want to switch to web reactive.
#EnableWebSecurity
#EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
#Import(SecurityProblemSupport.class)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter { }
After compiling, building and starting my application, If I hit the login url, then I get below error on the screen
Login with OAuth 2.0
[invalid_user_info_response] An error occurred while attempting to retrieve the UserInfo Resource: 403 Forbidden: [no body]
Browser's DevTools console shows that OAuth/authorization end point is returning with 200 http status with no values for session id and token, whereas ideally the end point should return with http status 302 along with session id and token.
I suspect, its related to the changes introduced by the version upgrade, because If I switch back to the older branch of the source code (having older version of jhipster like 6.4.1 and spring) , then the login works just fine.
Can anyone suggest what could be the possible reason behind this issue?
I believe that the 'authorize' end point returning 200 response with missing session id and token is surely one of the reasons.
Please guide me on this.
Thanks.
Thanks for the details. I have found the root cause. For the latest version of spring security, oidc: scope needs to be mentioned explicitly. something like this - scope: openid,profile,email. Adding this scope in application yml fixed the issue. –
I am currently working on a Spring Web services(SOAP) project. The requirement is to validate the request payload and return the error response if validation fails and log it. I have extended PayloadValidatingInterceptor to return custom validation message.
As part of logging requirement, we need to print the header values from Request Headers (HttpServletRequest) for tracking purpose.
How to access HttpServletRequest in the implementation of PayloadValidatingInterceptor?
Is it possible to inject HttpServletRequest?
version details:
Spring-Boot : 2.2.6
Spring-ws-core : 3.0.8
Please help.
After upgrading from Spring 5.2.x to 5.3.x, the error message
No mapping for POST /user/updateAccount.do
Completed 404 NOT_FOUND.
it was working fine when using spring 5.2.12 .RELEASE. If using spring 5.2.12 .RELEASE, this part of mapping message is : POST “/user/updateAccount.do”, parameters={masked} mapped to com.edu.user.controller.UpdateAccountController#handlePostRequest(HttpServletRequest, HttpSession,HttpServletResponse, updateAccountForm, BindingReault, Model) . Please advise why it has error :No mapping for POST after upgrade to spring 5.3.x
I'm in the process of migrating a Spring Boot 1.5 project to Spring Boot 2.1.8 (JDK 1.8, Kotlin 1.3.50).
I have a few controllers whose methods look like:
#PostMapping("post")
fun post(#RequestBody input: String): Callable<JsonNode> {
return Callable {
requestAsJson(input)
}
}
This works well in Spring Boot 1.5, without any further configuration. However with Spring Boot 2.1.8, the call does not fail but the HTTP response remains empty.
When I use start.spring.io to generate a minimalistic example, it works fine, so I guess that there is something wrong in my configuration.
When I enable debug traces for the Spring MVC, the final trace I get is:
[nio-8080-exec-3] m.m.a.RequestResponseBodyMethodProcessor : Writing [{"data":{"...
[nio-8080-exec-3] o.s.web.servlet.DispatcherServlet : Exiting from "ASYNC" dispatch, status 200
So this looks fine to me, but still no response is received (using Curl or Postman to test).
I'm a bit at a loss now, since it was working like a charm in Spring Boot 1.5 and I'm trying to get a hint on how to get out of this issue.
Thanks for any help,
Damien
I had declared a ShallowEtagHeaderFilter bean the following way in my WebMvcConfigurer:
#Bean
fun shallowEtagHeaderFilter(): ShallowEtagHeaderFilter {
return ShallowEtagHeaderFilter()
}
While this was working fine in Spring Boot 1.5, this causes the controller async methods (returning a Callable) to not return any content any longer. Removing this bean for Spring Boot 2.1 restores a normal behavior.
I still need to seek a way to have my e-tag, but for now, this solves the present issue.
I'm using spring-boot 1.5.0 RELEASE with swagger 2.6.1. I've added #EnableSwagger2 annotation on my spring boot application and defined a #Bean of type Docket. I've not used #EnableWebMvc annotation anywhere. I've excluded swagger-ui.html from security. When i call /v2/api-docs, i get the correct response JSON. But when i call /swagger-ui.html, it fails with HTTP 206. In chrome, it fails with Failed - No file. In console it shows the following error - Resource interpreted as Document but transferred with MIME type multipart/byteranges: "http://localhost:8080/swagger-ui.html".