One WildFly issue is that the application datasources aren't
available
until late in WildFly deployment but the JPA container needs to register
the JPA classloader level transformers very early, so Hibernate can rewrite
application classes. This is further complicated by our WildFly CDI
implementation needing to read application class definitions.
I wonder if it could make sense for
org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder
to have a separate way to register the ClassTransformer transformer early
and trigger the PU bootstrap on the first call to registered
ClassTransformer's. If that doesn't happen, then we defer bootstrap until
EntityManagerFactoryBuilder.build() is called.
Related question, does ORM need the DatabaseMetaData to performs bytecode
enhancing? Knowing the answer to that, will help answer my question above.
Scott