Home > database >  404 error on logout with WAR exploded to Tomcat
404 error on logout with WAR exploded to Tomcat

Time:11-19

My application works fine when I use embedded Tomcat (with IntelliJ) but when I deploy WAR file on Tomcat 8 one of my URLs response with 404 (I can sign in into my application but logout with URL responses with 404). This problem doesn't happen when I use IntelliJ with Tomcat.

My POM file:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.6.2</version>
    <relativePath/> <
</parent>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-aop</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>

Config file:

protected void configure(HttpSecurity http) throws Exception {

    http
        .csrf().disable();
    http
        .headers()
            .frameOptions().disable();

    http
        .authorizeRequests()
            .anyRequest().permitAll();
}

Update

I change to Tomcat 9 and I still have the problem.

Update_2

I have JSF view

CodePudding user response:

I figured out tomcat has promblem with api without page then i create a button and call the method :

 public void logout(){
    userAuthService.logout();
    FacesContext.getCurrentInstance().getExternalContext()
         .invalidateSession();
    FacesContext.getCurrentInstance().getExternalContext()
         .redirect("login.xhtml?faces-redirect=true");
}
  • Related