Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Security Turning On Spring Security with Java Config

gettin IllegalArgumentException on login

I got the following exception as i wanted to loging: java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null" Can someone help to solve this exception?

1 Answer

9,835 Points

Hello Freshta Moheby, in case you didn't figure this out yet. You might be using the newest Spring Security (version 5+) and it requires you to use encrypted passwords for production database handling. Since this isn't a production database, you need to specify in the SQL import file that these passwords are for testing purposes only. To do this, add {noop} in front of your passwords. Example line:

insert into user (username,enabled,password,role_id) values ('user', true, '{noop}password', 1);

If you have solved it, I hope someone else finds this useful.