The issue you are facing boils down to this: EntityManager(s) (EM) in JPA can be created multiple ways.
Tapestry-JPA manages / creates it's own EntityManagerFactory (EMF) and EMs It also reads persistence.xml on its own, and follows its own rules as far as having to have entities in a specific package (i.e. xxx.xxx.entities) When you use @PersistenceContext in Tapestry context, you are actually using the infrastructure (EMF and EMs) managed by Tapestry-JPA. Glassfish and the EJB container manage EMFs and EMs on their own, in a different, completely disconnected way. If you are using both, you will have two JPA caches and two instances of JPA infrastructure. When you do this: factory = Persistence.createEntityManagerFactory("de.aeits_TapestryWeb_war_1.0-SNAPSHOTPU"); > entityManager = factory.createEntityManager(); you are creating EMF by yourself and that will read persistence.xml yet again, completely disconnected from Tapestry or the EJB container. Tapestry-JPA is a tricky beast to use when you have more than one PU defined in your persistence.xml. It works fine if you define all your classes manually in persistence.xml, but in case of auto-scanning for entities, it's hard to get that working correctly (manual configuration / scanning is required) In my own projects, I wound up not using tapestry-JPA at all. I just call EJBs using FlowLogix library and let EJBs do all my database handling. I did create a bit of infrastructure (1500 lines of code or so) that includes GenericDAO, and GridDataSource that call EJBs to get their data generically. It's not public now, but if need be I can make it so. On Oct 11, 2013, at 9:22 AM, Andreas Ernst wrote: > Am 11.10.13 14:52, schrieb Dmitry Gusev: >> What is the name and location of your persistence.xml file? >> >> Is it src/main/resources/META-INF/persistence.xml ? > > Yes, it is: > > /Users/andreas/Documents/NetBeansProjects/TapestryWeb/src/main/resources/META-INF/persistence.xml > > And deployed under: > /Users/andreas/Documents/NetBeansProjects/TapestryWeb/target/TapestryWeb/WEB-INF/classes/META-INF/persistence.xml > > >> It looks like it can't find any PUs with the given name in your >> configuration: >> >> https://github.com/apache/tapestry-5/blob/master/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/EntityManagerSourceImpl.java#L212-L214 > > Hhmm, but why is this working? > > public List<Customers> getCustomers() { > factory = > Persistence.createEntityManagerFactory("de.aeits_TapestryWeb_war_1.0-SNAPSHOTPU"); > entityManager = factory.createEntityManager(); > return entityManager.createNamedQuery("Customer.findAll").getResultList(); > } > > Here the PU is found. I checked it just with Tomcat 7, the same error. > > -- > ae | Andreas Ernst | IT Spektrum > Postfach 5, 65612 Beselich > Schupbacher Str. 32, 65614 Beselich, Germany > Tel: +49-6484-91002 Fax: +49-6484-91003 > a...@ae-online.de | www.ae-online.de > www.tachyon-online.de > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org