I'd like to do a login page for my web application. On my example project that I found on internet for integrating Spring Security and LDAP, I got it working. When I tried to integrate working example to real app, I'm always gettin NullPointerException.
-
Please do not use 'tags' in the title next time and post xhtml and version info of relevant libraries. – Kukeltje Jul 27 '15 at 15:11
2 Answers
You have both spring annotation AND jsf annotations on the same class, so if you refer to them by different names (like you most likely did seeing your own 'answer'), you get different instances. That is not good and the cause of your original problem. Most likely (and you did not post your xhtml) you referred to the bean in your xhtml as loginViewBean
. Now you removed that AND (I suspect) you started referring to it as loginView
, you got the Spring managed instance back with the authenticationManager injected, instead of the JSF managed one without the authenticationManger injected. This resulted in the NPE. That you got the Spring one back then is most likely caused by the SpringEL resolver that you configured having precedence over the default JSF resolver. So removing the @ManagedBean
and @RequestScoped
AND refering to the bean by the spring name would have solved the problem to and in a better way.
See also
-
Thanks for reply and information. I know why it works now. Thank you very much. – Okan Binli Jul 28 '15 at 16:55
Solved my question.
I just need to edit this line
@ManagedBean(name = "loginViewBean")
to
@ManagedBean
And do the rest configuration on login.xhtml file. And it's done.

- 39
- 1
- 7