Legacy Knowledge Base
Published Sep. 10, 2025

Error java.lang.OutOfMemoryError: Metaspace

Written By

Alfonso Abad

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

Issue

  • When there's a lot of traffic or usage, the logs show an error similar to:
2019-11-12 07:39:54.538 ERROR [liferay/scheduler_dispatch-24][ParallelDestination:55] Unable to process message {destinationName=liferay/scheduler_dispatch, response=null, responseDestinationName=null, responseId=null, payload=null, values={GROUP_NAME=com.liferay.trash.web.internal.messaging.CheckEntryMessageListener, companyId=0, groupId=0, DESTINATION_NAME=liferay/scheduler_dispatch, EXCEPTIONS_MAX_SIZE=0, JOB_STATE=com.liferay.portal.kernel.scheduler.JobState@7678be23, STORAGE_TYPE=MEMORY_CLUSTERED, JOB_NAME=com.liferay.trash.web.internal.messaging.CheckEntryMessageListener}}
com.liferay.portal.kernel.messaging.MessageListenerException: com.liferay.portal.kernel.exception.SystemException: java.lang.reflect.InvocationTargetException
 at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:32)
 at com.liferay.portal.kernel.scheduler.messaging.SchedulerEventMessageListenerWrapper.receive(SchedulerEventMessageListenerWrapper.java:66)
 at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:74)
 at com.liferay.portal.kernel.messaging.ParallelDestination$1.run(ParallelDestination.java:52)
 at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask._runTask(ThreadPoolExecutor.java:756)
 at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask.run(ThreadPoolExecutor.java:667)
 at java.lang.Thread.run(Thread.java:748)
Caused by: com.liferay.portal.kernel.exception.SystemException: java.lang.reflect.InvocationTargetException
 at com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery.executeDynamicQuery(DefaultActionableDynamicQuery.java:373)
 at com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery$1.call(DefaultActionableDynamicQuery.java:282)
 at com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery$1.call(DefaultActionableDynamicQuery.java:278)
 at com.liferay.portal.spring.transaction.TransactionInvokerImpl$CallableMethodInvocation.proceed(TransactionInvokerImpl.java:101)
 at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:54)
 at com.liferay.portal.spring.transaction.TransactionInvokerImpl.invoke(TransactionInvokerImpl.java:47)
 at com.liferay.portal.kernel.transaction.TransactionInvokerUtil.invoke(TransactionInvokerUtil.java:28)
 at com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery.doPerformActions(DefaultActionableDynamicQuery.java:339)
 at com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery.performActions(DefaultActionableDynamicQuery.java:86)
 at com.liferay.portlet.trash.service.impl.TrashEntryLocalServiceImpl.checkEntries(TrashEntryLocalServiceImpl.java:184)
 at sun.reflect.GeneratedMethodAccessor3472.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
 at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:163)
 at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:54)
 at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:58)
 at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:137)
 at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
 at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:137)
 at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:169)
 at com.sun.proxy.$Proxy149.checkEntries(Unknown Source)
 at com.liferay.trash.web.internal.messaging.CheckEntryMessageListener.doReceive(CheckEntryMessageListener.java:71)
 at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:26)
 ... 6 more
Caused by: java.lang.reflect.InvocationTargetException
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
 at com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery.executeDynamicQuery(DefaultActionableDynamicQuery.java:361)
 ... 28 more
Caused by: java.lang.OutOfMemoryError: Metaspace

Environment

  • DXP 7.0

Resolution

  • Go to$[Tomcat-home]/bin and on the file setenv.sh find the variables:
-XX:MetaspaceSize=XYZm -XX:MaxMetaspaceSize=ABCm \
  • The error is shown because the portal  ran out of Metaspace. The values XYZ and ABC must be higher. The value will depend on the customer's infrastructure.

Additional Information

Did this article resolve your issue ?

Legacy Knowledge Base