I've been trying to follow the Keycloak tutorial from DZone (EDIT: which seems to be a nearly verbatim repost from the tutorial on the official Keycloak blog, apparently by the same author), but I've run into the following problems:
index.html
not being found
when clicking on the link to the interior page, the error
We're sorry...
Page not found
on that same page, the error
javax.servlet.ServletException: Circular view path [products]: would dispatch back to the current handler URL [/products] again.
the Keycloak admin panel appearing instead of the sample app
What am I doing wrong?
There are a number of subtle but significant inconsistencies/typos in that tutorial. In order of appearance:
the location of index.html
is given as /src/resources/static
. If you are using Spring Initializr, the pre-made code will have both main
and test
directories under src
, so the correct location will instead be src/main/resources/static
.
In the code for the controller, line 9 is
return "products";
This tells Spring to use products.html
. The actual HTML file will be product
, singular, because it is generated from product.ftl
. Take the 's' off of the return value.
In the application.properties
file, one of the lines given is
keycloak.realm=springboot
Earlier, when in the Keycloak admin panel, the guide suggested naming the realm "SpringBoot". These values need to match, and they are case-sensitive. Change either one.
After setup is complete, the instructions say
Now browse to “http://localhost:8080”
The correct URL is http://localhost:8081
, since server.port
was set to 8081 in application.properties
. Port 8080 should still be in use by the admin console.
With these changes, the test app should load and behave as described.
Be careful not to reintroduce the products
/product
typo when copying in the new getProducts()
method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With