java.lang.OutOfMemoryError: Metaspace when deploying a persistence unit in EAP

Solution Verified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) (all versions)
  • Hibernate (all versions)

Issue

  • Deploying an archive containing a persistence unit and a large number of classes/interfaces
  • java.lang.OutOfMemoryError: Metaspace occurs during the deployment process

Resolution

This is a This content is not included.known issue resolved as part of:

For any release line the latest available cumulative patch (CP) should be applied.

The following approaches may be adequate to avoid the issue in older releases:

Root Cause

While scanning for Hibernate annotations in the classes within the deployment archive, a new class loader is created and cached for each class and interface within the deployment archive.

Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.