Buggy code:
public class PersistenceContextInjectorService implements Service < ManagedReferenceFactory > { private final PersistenceContextType type ; private final PersistenceContextInjectorService . PersistenceContextJndiInjectable injectable ; public PersistenceContextInjectorService ( final AnnotationInstance annotation , final ServiceName puServiceName , final DeploymentUnit deploymentUnit , final String scopedPuName , final String injectionTypeName ) { } @ Override public void start ( StartContext context ) throws StartException { } @ Override public void stop ( StopContext context ) { } @ Override public ManagedReferenceFactory getValue ( ) throws IllegalArgumentException , IllegalStateException { } private static final class PersistenceContextJndiInjectable implements ManagedReferenceFactory { private final ServiceName puServiceName ; private final DeploymentUnit deploymentUnit ; private final PersistenceContextType type ; private final Map properties ; private final String unitName ; private final String injectionTypeName ; private static final String ENTITY_MANAGER_CLASS = "javax.persistence.EntityManager" ; public PersistenceContextJndiInjectable ( final ServiceName puServiceName , final DeploymentUnit deploymentUnit , final PersistenceContextType type , final Map properties , final String unitName , final String injectionTypeName ) { } @ Override public ManagedReference getReference ( ) { PersistenceUnitService service = ( ( PersistenceUnitService ) ( deploymentUnit . getServiceRegistry ( ) . getRequiredService ( puServiceName ) . getValue ( ) ) ) ; EntityManagerFactory emf = service . getEntityManagerFactory ( ) ; EntityManager entityManager ; if ( type . equals ( TRANSACTION ) ) { entityManager = new org . jboss . as . jpa . container . TransactionScopedEntityManager ( unitName , properties , emf ) ; } else { EntityManager entityManager1 = SFSBCallStack . findPersistenceContext ( unitName ) ; if ( entityManager1 == null ) { entityManager1 = emf . createEntityManager ( properties ) ; <START_BUG> entityManager = new org . jboss . as . jpa . container . ExtendedEntityManager ( entityManager1 ) ; <END_BUG> SFSBXPCMap . RegisterPersistenceContext ( entityManager ) ; } else { entityManager = entityManager1 ; } } if ( ! ( PersistenceContextInjectorService . PersistenceContextJndiInjectable . ENTITY_MANAGER_CLASS . equals ( injectionTypeName ) ) ) { Class extensionClass ; try { extensionClass = this . getClass ( ) . getClassLoader ( ) . loadClass ( injectionTypeName ) ; } catch ( ClassNotFoundException e ) { throw new RuntimeException ( ( ( "couldn't<seq2seq4repair_space>load<seq2seq4repair_space>" + ( injectionTypeName ) ) + "<seq2seq4repair_space>from<seq2seq4repair_space>JPA<seq2seq4repair_space>modules<seq2seq4repair_space>classloader" ) , e ) ; } Object targetValueToInject = entityManager . unwrap ( extensionClass ) ; new ValueManagedReference ( new org . jboss . msc . value . ImmediateValue < Object > ( targetValueToInject ) ) ; } return new ValueManagedReference ( new org . jboss . msc . value . ImmediateValue < Object > ( entityManager ) ) ; } } }

Fix:
entityManager = new org . jboss . as . jpa . container . ExtendedEntityManager ( unitName , entityManager1 ) ;