This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problems with validation and getting data from EJB

 
Karol Oslowski
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,

I'm trying to write a custom validator as described here

The validator is intended for use with new users registering and he has to check whether the login given by user is still available. Therefore I need to connect with the data layer to execute a finder on users. Is there any simple way of doing that?

@PersistenceContext
private EntityManager em;

doesn't help since validator aint a bean.

Thanks in advance for any help,

Kind Regards,

karol
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Going by the validator example that you pointed out, the Validator appears to be just some simple Java class. Instead of injecting the EntityManager, you can look up the EntityManager through JNDI lookup code, in your validator class. By default in JBoss, the EntityManager is not available in the JNDI. Go through this chapter ("Persistence unit JNDI Bindings" section) which explains how to make the EntityManager available in the JNDI tree, in JBoss.
 
Karol Oslowski
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for this answer. I'm getting the context throught jndi lookup and all is working fine!

Cheers,

k.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic