Java Persistence API in a JavaServer Faces web application

K

kandlinger

Hi all,
I read that the container managed entity managers are not only working
in EJBs but also in Beans listed in the faces-config.xml. I used a
manual created entity manager with success in my JSF application. But
now I reached a point where a container-managed entity manager would be
nice. Because the entity manager needs to survive the whole session,
and so i cannot close him. So I tried to use a container-managed one
with the following code:

@PersistenceContext(unitName="persistence_unit")
protected EntityManager em;

The problem is, that this container-managed entity-manager doesn't
work. I doesn't connect to the database i specified in persistence.xml.
It always wants to connect to the derby-database shipped with the sun
appliction server 9. But the manual created entity managers are using
the database server I specified in persistence.xml.
Anybody knows the solution ?
Is it correct to place the persistence.xml in
/WEB-INF/classes/META-INF/persistence.xml inside the .war file ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top