• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

[Spring Security] problem with UserDetailsService implementation

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Robert Tomson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 .........."
reply
    Bookmark Topic Watch Topic
  • New Topic