| Author |
problems with validation and getting data from EJB
|
Karol Oslowski
Ranch Hand
Joined: Jul 22, 2005
Posts: 51
|
|
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
Joined: Jul 20, 2005
Posts: 8141
|
|
|
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.
|
[My Blog] [JavaRanch Journal]
|
 |
Karol Oslowski
Ranch Hand
Joined: Jul 22, 2005
Posts: 51
|
|
Thanks a lot for this answer. I'm getting the context throught jndi lookup and all is working fine! Cheers, k.
|
 |
 |
|
|
subject: problems with validation and getting data from EJB
|
|
|