The EntityManager type that the application can obtain is the proxy class of EntityManager provided by Application Server and not the EntityManager object provided by the JPA provider.
The EntityManager object can be obtained by using injection, JNDI lookup, or EntityManagerFactory.
Note that to use injection for obtaining EntityManager, you set up javax.persistence.EntityManager as the field or method argument type that injects EntityManager.
Also, you cannot cast EntityManager obtained with injection, JNDI lookup, or EntityManagerFactory in the EntityManager implementation class of the JPA provider.
If you need to obtain the EntityManager object of the JPA provider, use the getDelegate method of the EntityManager proxy object obtained with injection, JNDI lookup, or EntityManagerFactory.