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
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 thejavax
tojakarta
.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
You can also try adding new dependencies as follows. With the below dependencies I was able to retain javax.servlet class.