java.lang.OutOfMemoryError: Metaspace when deploying a persistence unit in EAP
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: Metaspaceoccurs during the deployment process
Resolution
This is a This content is not included.known issue resolved as part of:
- This content is not included.EAP 7.1 GA and later1
- This content is not included.EAP 7.0 cumulative patch (CP) 4 and later2
- This content is not included.EAP 6.4 cumulative patch (CP) 13 and later3
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:
- Increase the metaspace allocation
- Refactor the archive to remove classes not directly related to / required by the persistence unit
See Content from issues.jboss.org is not included.JBEAP-6739
2: See Content from issues.jboss.org is not included.JBEAP-6741
3: See This content is not included.BZ-1390207
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.
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.