[jboss-user] [EJB 3.0] - EntityManagerFactory creation failure EJB 2.1 - EJB 3.0
rkite01
do-not-reply at jboss.com
Tue May 8 10:55:50 EDT 2007
I have a sample application I am using to learn EJB 3.0. I am having a problem accessing EJB 3.0 beans from an EJB 2.1 session bean. I can not get an EntityManagerFactory. I need an EntityManager to perform an EJB 3.0 finder from the 2.1 Session bean. I am using JBoss 4.2 CR2. Using EJB 3.0 session and entity Beans together is not a problem. What else needs to be done?
Here is the error I am getting from the EntityManagerFactory creation line.
10:52:50,799 INFO [SettingsFactory] Default entity-mode: pojo
10:52:50,799 INFO [SettingsFactory] Named query checking : enabled
10:52:50,799 INFO [SessionFactoryImpl] building session factory
10:52:50,815 INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no
JNDI name configured
10:52:50,815 ERROR [LogInterceptor] RuntimeException in method: public abstract
java.util.TreeSet com.ejb.UserManager.retrieveMessages(java.lang.String) throws
java.lang.Exception,java.rmi.RemoteException:
javax.persistence.PersistenceException: org.hibernate.HibernateException: The ch
osen transaction strategy requires access to the JTA TransactionManager
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Con
figuration.java:720)
// Example of getting EJB 3.0 beans from EJB 2.1 Session Bean.
public List findPosts(String userLogin) throws Exception
{
HashMap map = new HashMap();
InitialContext initialContext = new InitialContext();
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("imEjb30", map);
EntityManager entityManager = entityManagerFactory.createEntityManager();
entityManagerFactory.close();
Query query = entityManager.createNamedQuery("findPosts");
query.setParameter(0, userLogin);
List list = query.setMaxResults(10).setFirstResult(0).getResultList();
return(list);
}
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4043950#4043950
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4043950
More information about the jboss-user
mailing list