Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Java Spring Cloud - Cannot send a request from one service to another one through Api Gateway

datdatyul

Active Coder
I have an issue not sending a request from one service to another one through api gateway in my spring cloud example,

Api gateway port number is 8600.

I try to send a request from management service to advertisement service through api gateway, I get the issue in Postman shown below.

{ "timestamp": "2022-08-29T11:48:40.168+00:00", "path": "/api/v1/admin_role/alladvertisements", "status": 404, "error": "Not Found", "message": null, "requestId": "8764de5c-7" }


Here is my Security Config of management service shown below.

@Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(jsr250Enabled = true) public class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { super.configure(http); http.csrf().disable(); http.authorizeRequests() .antMatchers("/api/v1/admin_role/*").hasAnyRole("ROLE_ADMIN") .antMatchers("/api/v1/user_role/*").hasAnyRole("ROLE_USER") .antMatchers("/actuator/health").hasAnyRole("ROLE_ADMIN") .antMatchers("/actuator/circuitbreakerevents").hasAnyRole("ROLE_ADMIN") .anyRequest() .permitAll(); } @Autowired protected void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { KeycloakAuthenticationProvider provider = keycloakAuthenticationProvider(); provider.setGrantedAuthoritiesMapper(new SimpleAuthorityMapper()); auth.authenticationProvider(provider); } @Override @Bean protected SessionAuthenticationStrategy sessionAuthenticationStrategy() { return new RegisterSessionAuthenticationStrategy(new SessionRegistryImpl()); } }

How can I fix the issue?

Here is my project link : [Link][1]


[1]: https://github.com/Rapter1990/SpringBootMicroservices


Here is my controller in Management Service

@RestController @RequestMapping("/api/v1/admin_role") @RequiredArgsConstructor public class AdminController { private final AdminService adminService; @GetMapping("/alladvertisements") @CircuitBreaker(name = "management", fallbackMethod = "managementFallback") public ResponseEntity<List<Advertisement>> getAllAdvertisements(){ LOGGER.info("AdminController | getAllAdvertisements is started"); return ResponseEntity.ok(adminService.getAllAdvertisements()); } }
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom