problems with validation and getting data from EJB
Joined: Jul 22, 2005
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?
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.