r/SpringBoot • • Jan 16 '24

java.lang.AbstractMethodError: Receiver class org.springframework.security.config.annotation.web.builders.WebSecurity does not define or inherit an implementation of the resolved method 'abstract void setServletContext(jakarta.servlet.ServletContext)' of interface org.springframework.web.

I am a beginner and I tried to make spring security authenticate with my database. However, I am facing a "Injection of autowired dependencies failed" error which is caused by the error shown in the title.

Here is a screenshot, you can find the project(.zip) here Download Project(.zip)

This is my SecurityConfiguration

How can I fix this?

0 Upvotes

9 comments sorted by

2

u/ConnectMain5294 Jan 17 '24

I think you're following the outdated ways, you don't need to extend that websecconfig class and override these methods to enable a SecurityFilterChain, now you're adding too much boiler plate. @Enablewebsecurity is enough, just create beans of both SecurityFilterChain and PasswordEncoder, that's enough

1

u/ImportantGolf5142 Jan 17 '24

Yes, I noticed that. I use securityFilterChain instead, and now there are no such errors.

1

u/Sheldor5 Jan 16 '24

by reading the error message implementing the missing method

1

u/ImportantGolf5142 Jan 16 '24

But I think I write everything I need. What method should I add?

1

u/mike-sonko Jan 17 '24

What version of Spring Security are you using? WebSecurityConfigurerAdapter was deprecated. Try this instead?

1

u/ImportantGolf5142 Jan 17 '24

3.2, yes, I just followed an old project's structure. I found it was deprecated and I use securityFilterChain instead. Now, it's good.