I'm using Eclipselink's implementation of JPA and this is how I'm instantiating persistence context:
@PicketLink
@PersistenceContext(unitName = "txPersistUnit.security")
private EntityManager txEmSec;
this is persistence unit defitnition:
<persistence-unit name="txPersistUnit.security" transaction-type="RESOURCE_LOCAL">
...
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.target-database" value="PostgreSQL"/>
<property name="eclipselink.cache.shared.default" value="true"/>
...
<!-- EclipseLink should create the database schema automatically -->
<property name="eclipselink.ddl-generation" value="create-or-extend-tables"/>
<property name="eclipselink.ddl-generation.output-mode"
value="database"/>
</properties>
</persistence-unit>
so, you can see I am setting RESOURCE_LOCAL as a transaction-type but I'm getting this error when deploying:
java.io.IOException: com.sun.enterprise.admin.remote.RemoteFailureException: Error occurred during deployment: Exception while preparing the app : The persistence-context-ref-name [com.txsolutions.manager.PersistenceManager/txEmSec] in module [txAPI] resolves to a persistence unit called [txPersistUnit.security] which is of type RESOURCE_LOCAL. Only persistence units with transaction type JTA can be used as a container managed entity manager. Please verify your application.. Please see server.log for more details.
Server is Glassfish 4.0.1 Question is why is glassfish not deploying this application succesfully when transaction-type set to RESOURCE_LOCAL? I'm emphasizing that I have RESOURCE_LOCAL persistence unit in that same application on that same server deployed.
Now, when I create entity manager like this:
..declarations omitted..
factory = Persistence.createEntityManagerFactory("txPersistUnit.security");
entityManager = factory.createEntityManager();
it is created sucessfuly even with RESOURCE_LOCAL as for transaction type.
So all in all whats the difference between this two approaches?
Thanks!