aspose file tools*
The moose likes Spring and the fly likes [Spring Security] problem with UserDetailsService implementation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "[Spring Security] problem with UserDetailsService implementation" Watch "[Spring Security] problem with UserDetailsService implementation" New topic
Author

[Spring Security] problem with UserDetailsService implementation

Robert Tomson
Greenhorn

Joined: Nov 12, 2010
Posts: 9
hi, i have created simple CRUD app(beginner here) which is working fine, so now i want to add authentication

after trial of errors i am finally able to successfully deploy my app, but at first login attempt i am receiving :

my UserDetailsService implementation

part of applicationContext-security.xml


is it possible to use @EJB annotation in UserDetailsService, same way i am using it in JSF Managed Bean ?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

It looks like the username is not being passed in.

Try putting breakpoint in your userdetails and seeing what is null.

You are using j_username in your username field on your form, correct?

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Robert Tomson
Greenhorn

Joined: Nov 12, 2010
Posts: 9
Mark Spritzler wrote:It looks like the username is not being passed in.

Try putting breakpoint in your userdetails and seeing what is null.

You are using j_username in your username field on your form, correct?

Mark


username is correct, i am using login form generated by spring.

but my userDAO is null, and thats the problem

edit : i probably need to use jndi lookup, looking into this right now

eidt 2: got it
1) added in web.xml
2)
in my UserDetailsService


still if there is better/more 'pro' way i would like to here it :P
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

I @Autowired depenencies into my UserDetailsService

@Autowired
private AccountSystem accountSystem;

So you can make your ejb class a bean in your xml configuration. I suggest using the jee namespace. It has a tag to do an EJB lookup and the bean is the EJB. Then you just inject it into your UserDetailsService. You might still need that entry in your web.xml, but I am leaning towards not needing it.

Mark
Robert Tomson
Greenhorn

Joined: Nov 12, 2010
Posts: 9
now I can see how missed this topic subject is, cause its all about getting reference to ejb,

anyway, i have recreated this project but now with maven and the problem is back ^^ my ejb is null again
i had to remove from web.xml

added
(name="UserDAOBean") to @Stateless annotation of my UserDAOBean

so now iam using it like this in JSF Managed Bean

@Mark Spritzler
i have tried to do as you suggested, as far as i could understand it, but with no luck , and of course i dont know if it still applies to my new(maven) situation

can you explain it in 'simple english', like for an idiot :P
hope i dont ask for too much
Robert Tomson
Greenhorn

Joined: Nov 12, 2010
Posts: 9
got it again,
now my jndi lookup start with "java:global/...."

i only succeeded because there was server log entry "INFO: Portable JNDI names for EJB UserDAOBean .........."
 
 
subject: [Spring Security] problem with UserDetailsService implementation