ARTICLE AD BOX
I have a project I'm converting from Java EE to Jakarta 10. I'm trying to get the persistence to work on Glassfish 7. Unfortunately when the application is deployed to Glassfish I get the following error:
java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName myApp at com.sun.enterprise.container.common.impl.EntityManagerWrapper.init(EntityManagerWrapper.java:130) at com.sun.enterprise.container.common.impl.EntityManagerWrapper.doTxRequiredCheck(EntityManagerWrapper.java:148) at com.sun.enterprise.container.common.impl.EntityManagerWrapper.doTransactionScopedTxCheck(EntityManagerWrapper.java:141) at com.sun.enterprise.container.common.impl.EntityManagerWrapper.persist(EntityManagerWrapper.java:268) at politse.ejb.RequestBean.createParliament(RequestBean.java:109)The relevant parts of my RequestBean are:
@Named("requestBean") @RequestScoped @Stateful public class RequestBean { PersistenceContext(unitName="myApp") private EntityManager em; public void createParliament(String parliamentId) { Parliament wst = new Parliament(parliamentId); em.persist(wst); //exception here } }My persistence.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?> <persistence version="3.0" xmlns="https://jakarta.ee/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"> <persistence-unit name="myApp" transaction-type="JTA"> <jta-data-source>jdbc/MySQLPool</jta-data-source> <exclude-unlisted-classes>false</exclude-unlisted-classes> <properties> <property name="jakarta.persistence.schema-generation.database.action" value="drop-and-create"/> <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/> <property name="eclipselink.ddl-generation.output-mode" value="both"/> </properties> </persistence-unit> </persistence>What I don't understand is I'm trying to use container managed persistence, and according to the Jakarta tutorial the EntityManagerFactory is only required when using application managed persistence. So I'm not sure why Glassfish thinks I want to use application managed persistence.
Thanks,
Zobbo
1743 silver badges15 bronze badges
Explore related questions
See similar questions with these tags.
