Spring Boot Application on Tomcat 11 Returns 404 on Valid Endpoint

I am trying to deploy a Spring Boot Application on Tomcat11, but I am getting a 404 error when sending requests to valid endpoint.

I am using Java 21, Spring Boot 3.3.0 on Tomcat 11 with port 8082.

My application.properties file:

`cors.allowed-origins=http://localhost:3000
cors.allowed-headers=*
cors.allow-credentials=true
cors.allowed-methods=GET,POST,PUT,DELETE,OPTIONS

spring.application.name=ivr-test-automation-backend
server.port=8082
spring.datasource.url=jdbc:postgresql://POSTGREIP:5432/ivr_test
spring.datasource.username=test_app
spring.datasource.password=password
spring.datasource.hikari.schema=ivr_test_automation
spring.datasource.driver-class-name=org.postgresql.Driver
spring.sql.init.mode=always

spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

logging.level.org.springframework.web.reactive.function.client=WARN
logging.level.org.springframework=WARN
logging.level.root=WARN
logging.level.org.hibernate=WARN
logging.file.name=logs/ivr-test-automation-backend.log

spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.hibernate.format_sql=true

# JWT
remote.auth.url=http://LDAPIP:992/api/v1/authenticate/login
remote.auth.secret=IVRLdap-Password
#jwt.secret=ivrTestAutomationSecret
jwt.expiration=36000000
jwt.secret = ${jwt.secret}

spring.devtools.restart.enabled=true
spring.devtools.livereload.enabled=true`

My AuthController

@RestController
@RequestMapping("/api/v1/auth")
public class AuthController {
.
.
.
 @PostMapping("/login")
    public ResponseEntity<RestResponse<JwtAuthenticationResponse>> createAuthenticationToken(@RequestBody LoginRequest authRequest) throws Exception {
        authenticationManager.authenticate(
                new UsernamePasswordAuthenticationToken(authRequest.ldapName(), authRequest.password())
        );

        final UserDetails userDetails = userDetailsService.loadUserByUsername(authRequest.ldapName());
        final String jwt = jwtUtil.generateToken(userDetails);

        JwtAuthenticationResponse jwtAuthenticationResponse = getJwtAuthenticationResponse(authRequest.ldapName(), jwt);

        return ResponseEntity.ok(RestResponse.of(jwtAuthenticationResponse, AuthMessage.SUCCESSFUL_LOGIN));
    }
.
.
.

}

I am making the endpoint public with the following code block.

    @Bean
    public SecurityFilterChain securityFilterChain(HttpSecurity http, JwtTokenRefreshFilter jwtTokenRefreshFilter) throws Exception {
        http.csrf(AbstractHttpConfigurer::disable)
                .authorizeHttpRequests(auth -> auth
                        .requestMatchers("/api/v1/auth/**").permitAll()
                        .requestMatchers("/v3/api-docs/**", "/swagger-ui/**", "/swagger-ui.html").permitAll()
                        .requestMatchers("/api/v1/role/**").authenticated()
                        .requestMatchers("/api/v1/user/**").authenticated()
                        .requestMatchers("/api/v1/permission/**").authenticated()
                        .requestMatchers("/api/v1/blacklist/**").authenticated()
                        .requestMatchers("/api/v1/scenario-configuration/**").authenticated()
                        .requestMatchers("/api/v1/scenario-configuration-history/**").authenticated()
                        .anyRequest().authenticated())
                .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
                .authenticationProvider(customAuthProvider())
                .addFilterBefore(jwtTokenRefreshFilter, UsernamePasswordAuthenticationFilter.class)
                .addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class)
                .logout(logout -> logout
                        .logoutUrl("/api/v1/auth/logout")
                        .logoutSuccessHandler((request, response, authentication) -> {
                            response.setStatus(HttpServletResponse.SC_OK);
                            response.getWriter().write(AuthMessage.SUCCESSFUL_LOGOUT.getMessage());
                        }));
        return http.build();
    }

On tomcat in server.xml file I added the Connector port for 8082

<Connector port="8082" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />

When i run netstat -aon, the port is listening:

tcp6       0      0 :::8080                 :::*                    LISTEN      off (0.00/0/0)
tcp6       0      0 :::8081                 :::*                    LISTEN      off (0.00/0/0)
tcp6       0      0 :::8082                 :::*                    LISTEN      off (0.00/0/0)

These are my settings. When I send a request on http://SERVERIP:8082/api/v1/auth/login via postman, I get the following error.

The application seems to be running successfully in the logs on catalina.out.

Example log that show deployment is success:

05-Sep-2024 19:43:57.201 INFO [Catalina-utility-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/opt/tomcat/webapps/ivr-test-automation-backend-0.0.1-SNAPSHOT.war] has finished in [11,316] ms

What could be causing this 404 error for a valid endpoint, and how can I fix it? If there is any config setting you want me to show, I can show it.

Any help would be appreciated!

I tried to add address="0.0.0.0" to the server.xml file.

<Connector port="8082" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"
               address="0.0.0.0" />

Then it took this form. The resuld did not change.
And when i tried sudo firewall-cmd –list-all, shows me.

[root@S200OUT03 logs]# sudo firewall-cmd --list-all
FirewallD is not running

5

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật