Skip to content

Commit

Permalink
member of composite persistence unit with eclipselink.composite-unit.…
Browse files Browse the repository at this point in the history
…member=true gives NPE in EntityManagerSetupImpl#preInitializeCanonicalMetamodel

see https://bugs.eclipse.org/bugs/show_bug.cgi?id=558887
tested by composite.advanced tests

Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
  • Loading branch information
lukasj authored and rfelcman committed Jul 7, 2022
1 parent 0b681a8 commit 722dfdd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,8 @@ public class TraceLocalizationResource extends ListResourceBundle {
{ "jmx_mbean_classloader_in_use", "EclipseLink JMX Runtime Services is referencing the [{0}] ClassLoader at: [{1}]" },
{ "metamodel_itentifiableType_javaclass_null_cannot_set_supertype", "Metamodel processing: Unable to set the superclass Hierarchy because the javaClass field is null for the relationalDescriptor [{0}] for the identifiableType [{1}]." },
{ "metamodel_relationaldescriptor_not_fully_initialized_yet", "Metamodel processing: The relationalDescriptor [{0}] for the managedType [{1}] is not fully initialized yet - the Metamodel instance will be incomplete before at least one entityManger session login (after a full deploy)." },
{ "metamodel_type_collection_empty", "The collection of metamodel types is empty. Model classes may not have been found during entity search for Java SE and some Java EE container managed persistence units. Please verify that your entity classes are referenced in persistence.xml using either <class> elements or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element" },
{ "metamodel_not_preinit", "Metamodel for composite member [{0}] not preinitialized"},
{ "no_weaved_vh_method_found_verify_weaving_and_module_order", "An expected weaving method [{0}] was not found on the accessor [{2}] on the mapping [{1}] - verify that the processing order of your modules places the one containing a persistence unit ahead of modules that use it in your deployment descriptor, or disable weaving for the persistence context or the mapping using FetchType.EAGER." },
{ "proxy_connection_customizer_already_proxy_session", "{0}:{1}: proxy session with unknown properties is already opened. Closing it."},
{ "proxy_connection_customizer_opened_proxy_session", "{0}:{1}: opened proxy session."},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ protected void removeSessionFromGlobalSessionManager() {
public AbstractSession deploy(ClassLoader realClassLoader, Map additionalProperties) {
if (this.state != STATE_PREDEPLOYED && this.state != STATE_DEPLOYED && this.state != STATE_HALF_DEPLOYED) {
if (mustBeCompositeMember()) {
throw new PersistenceException(EntityManagerSetupException.compositeMemberCannotBeUsedStandalone(this.persistenceUnitInfo.getPersistenceUnitName()));
throw new IllegalStateException(EntityManagerSetupException.compositeMemberCannotBeUsedStandalone(this.persistenceUnitInfo.getPersistenceUnitName()));
}
throw new PersistenceException(EntityManagerSetupException.cannotDeployWithoutPredeploy(this.persistenceUnitInfo.getPersistenceUnitName(), this.state, this.persistenceException));
}
Expand Down Expand Up @@ -1754,7 +1754,7 @@ public synchronized ClassTransformer predeploy(PersistenceUnitInfo info, Map ext
return null;
} else {
// predeploy is used for static weaving
throw new PersistenceException(EntityManagerSetupException.compositeMemberCannotBeUsedStandalone(persistenceUnitInfo.getPersistenceUnitName()));
throw new IllegalStateException(EntityManagerSetupException.compositeMemberCannotBeUsedStandalone(persistenceUnitInfo.getPersistenceUnitName()));
}
}
}
Expand Down Expand Up @@ -4257,6 +4257,14 @@ public void preInitializeMetamodel(){
* to avoid having to further initialize the metamodel.
*/
public void preInitializeCanonicalMetamodel(EntityManagerFactoryImpl factory){
if (mustBeCompositeMember()) {
// composite member
// composite-unit can login and initialize (pre)initialize metamodel
// if we are composite member, we cannot login, we have no session and no operations are allowed,
// yet the factory can still be created as long as subsequent calls to createEntityManager fail with IllegalStateException
AbstractSessionLog.getLog().log(SessionLog.FINER, SessionLog.METAMODEL, "metamodel_not_preinit", getPersistenceUnitUniqueName());
return;
}
// 338837: verify that the collection is not empty - this would mean entities did not make it into the search path
if(null == metaModel.getManagedTypes() || metaModel.getManagedTypes().isEmpty()) {
getSession().log(SessionLog.FINER, SessionLog.METAMODEL, "metamodel_type_collection_empty");
Expand Down

0 comments on commit 722dfdd

Please sign in to comment.