skip to Main Content

When I ran spring-boot-2.7, there is no issue. However when I changed code and tailored it to spring-boot-3.0, there is java.lang.ClassNotFoundException: javax.servlet.http.HttpServletRequest

Could someone help me to download the source code and run on your computer? After run it, and you click "Login using Facebook", you will see the exception.
https://github.com/chuangtc/spring-boot-3.0-security-social-login

I tried adding jarkarta servlet api 6.0, but the exception is still there.

2

Answers


  1. You don’t have to add jakarta servlet api 6.0 into the pom.xml.
    According to documentation here, it is already included.

    In your code whichever is using javax.servlet.http.HttpServletRequest, you need to change the javax to jakarta.

    So the whole line will be something like this:
    import jakarta.servlet.http.HttpServletRequest

    I faced this error before when I upgrade my service as well and I solved it using this way. Maybe you can try it.

    [EDIT]

    I see that one of your dependency is using the javax.servlet:
    https://mvnrepository.com/artifact/org.springframework.social/spring-social-facebook/2.0.3.RELEASE

    And following this github, it seems this packages is no longer actively maintained and being archived, so it is likely they do not upgrade for Spring Boot 3.

    I would recommend find other ways to work on the social login for Facebook, maybe you can try this way?

    https://www.codejava.net/frameworks/spring-boot/social-login-with-facebook-example

    Login or Signup to reply.
  2. You can also try adding new dependencies as follows. With the below dependencies I was able to retain javax.servlet class.

     <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
            <version>1.3.2</version>
      </dependency> 
      <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.2.12</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency> 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search