As described in Accessing Databases from Web Applications, a persistence unit is defined by a persistence.xml file, which is packaged with the application WAR file. This file includes the following:
A persistence element that identifies the schema that the descriptor validates against and includes a persistence-unit element.
A persistence-unit element that identifies the name of a persistence unit and the transaction type.
An optional description element.
A jta-data-source element that specifies the global JNDI name of the JTA data source.
The jta-data-source element indicates that the transactions in which the entity manager takes part are JTA transactions, meaning that transactions are managed by the container. Alternatively, you can use resource-local transactions, which are transactions controlled by the application itself. In general, web application developers will use JTA transactions so that they don’t need to manually manage the life cycle of the EntityManager instance.
A resource-local entity manager cannot participate in global transactions. In addition, the web container will not roll back pending transactions left behind by poorly written applications.