Part 2: The Bug
Fixing the login bug
Decided you need some help? Here are some pointers.
Do you know yet where the error is coming from? What does the error message tell you?
”No AuthenticationProvider found for org.springframework.security.authentication.UsernamePasswordAuthenticationToken”
If it’s not obvious, this is thrown by Spring Security telling you the authentication process has not been set up correctly. The project is set up to use the plugin simple-users
developed by DigInG that provides some common user management functionality that all our apps need.
Ok - I need more help (scroll down)
Have you check the documentation for simple-users
to see if the app has been setup correctly?
Ok - I need more help
Check MvcConfig.java
, PersistenceConfig.java
, and RootConfig.java
. Are there any simple-users references that might need fixing?
Tell me the solution, I give up.
How to fix it
The three files MvcConfig.java
, PersistenceConfig.java
, and RootConfig.java
all load certain files from simple-users
. However, there is a bug in the artifact generating the project that overwrites the correct root package of these references with the root package of the app we created. For example the line
@ComponentScan("my.project.simpleusers.web")
in MvcConfig.java
references a package that does not exist. Instead it needs to point to the package simpleusers.web
of the simple-users
plugin. The correct code is:@ComponentScan("edu.asu.diging.simpleusers.web")
If you read the documentation of simple-users
, you find that exact line. It tells Spring to scan the package edu.asu.diging.simpleusers.web
for any Spring components (e.g. controllers, services, etc).
In MvcConfig.java
, there are other incorrect package references in the @EnableJpaRepositories
annotation (simpleusers.core.data
), and inside the entityManagerFactory
method em.setPackagesToScan(new String[] { "my.project.thymeleaf.core.model", "my.project.simpleusers.core.model" });
Lastly, there is another @ComponentScan
in RootConfig.java
that needs fixing:@ComponentScan({"my.project.thymeleaf", "my.project.simpleusers.core"})
Once you replace my.project
with edu.asu.diging
in the correct places, you should be able to login.