Seam-managed persistence contexts and Glassfish
niajp Mar 17, 2008 1:05 AMHello forum,
I have recently been learning about Seam for my current project and one of the things I am trying to figure out is seam-managed persistence context.
I have changed a simple hello world code to use seam-managed persistence context but I am not able to run it successfully on glassfish. I get following he error when I call getPeople() method in the ejb...
javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean; nested exception is: java.lang.IllegalArgumentException: EntityManagerFactory not found in JNDI : persistence/em
Here is the code snippet from various files..
Persistence.xml
<persistence-unit name="test" transaction-type="JTA"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>jdbc/Postgress</jta-data-source> <class>seam.entities.Person</class> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/> <property name="hibernate.hbm2ddl.auto" value="create-drop"/> </properties> </persistence-unit>
Code sippet from web.xml
<persistence-unit-ref> <persistence-unit-ref-name>persistence/em</persistence-unit-ref-name> <persistence-unit-name>test</persistence-unit-name> </persistence-unit-ref> <ejb-local-ref> <ejb-ref-name>DataBean</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local>seam.beans.DataLocal</local> </ejb-local-ref>
Code snippet form component.xml
<persistence:managed-persistence-context name="em" auto-create="true" persistence-unit-jndi-name="persistence/em"/> <core:init jndi-pattern="java:comp/env/#{ejbName}" debug="false"/>
Code snippet from the DataBean
@Stateless @Name("dataBean") @Interceptors({org.jboss.seam.ejb.SeamInterceptor.class}) public class DataBean implements DataLocal { ... ... @In private EntityManager em; private int countPeople; @Override public String getPeople() { em.persist(person); person = new Person(); setFans((List<Person>) em.createQuery("select p from Person p").getResultList()); return null; } ... ... }
What else I am missing?
Any help you can provide will be much appreciated.
Thank You.