tags:

views:

138

answers:

1

I came aboard a new project with a new company and we are trying to use JPA to do some DB work. So we have an Ear with an EJB, a webservice, and then there is a app client in the ear that really does all the work. The Webservice, calls the EJB, and the EJB calls the client to do the DB work. So within the appclient I want to load an EntityManager via annotations, but it does not seem to work (em is always null): @Entity public class Whatever...{ @PersistenceContext(unitName="pu") EntityManager em;

}

So I was thinking that I need to load the EntityManager at the EJB, but that didn't work either, because it seems that JPA didn't see the Entity classes since they are in the appclient and not the EJB. Can anyone give me some guidance?

+1  A: 

This is a misuse of an app client. All your db processing should occur in the EJB. There doesn't seem to be any apparent reason for the app clients' existence.

This link is to an old article, but gives examples as to what an app client is used for (Applications not backend services).

Application Client

Robin