Liferay 7 – javax.servlet.ServletException: java.lang.NoClassDefFoundError

If you run into this issue, how to solve it?

2018-07-09 21:44:54.986 ERROR [http-nio-8443-exec-2][status_jsp:911] com.liferay.portal.kernel.portlet.PortletContainerException: com.liferay.portal.kernel.portlet.PortletContainerException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/liferay/docs/guestbook/model/Guestbook
2018-07-09 21:44:55.030 ERROR [liferay/monitoring-1][ParallelDestination:55] Unable to process message {destinationName=liferay/monitoring, response=null, responseDestinationName=null, responseId=null, payload=[{displayName=Hello World, portletId=com_liferay_hello_world_web_portlet_HelloWorldPortlet, requestType=RENDER, {attributes=null, companyId=20115, groupId=32711, description=null, duration=0, name=com_liferay_hello_world_web_portlet_HelloWorldPortlet, namespace=com.liferay.monitoring.Portlet, requestStatus=SUCCESS, stopWatch=0:00:00.000, timeout=0, user=null}}, {displayName=Guestbook, portletId=com_liferay_docs_guestbook_portlet_GuestbookPortlet, requestType=RENDER, {attributes=null, companyId=20115, groupId=32711, description=null, duration=0, name=com_liferay_docs_guestbook_portlet_GuestbookPortlet, namespace=com.liferay.monitoring.Portlet, requestStatus=null, stopWatch=0:00:00.234, timeout=0, user=null}}, {displayName=User Personal Bar, portletId=com_liferay_product_navigation_user_personal_bar_web_portlet_ProductNavigationUserPersonalBarPortlet, requestType=RENDER, {attributes=null, companyId=20115, groupId=32711, description=null, duration=1, name=com_liferay_product_navigation_user_personal_bar_web_portlet_ProductNavigationUserPersonalBarPortlet, namespace=com.liferay.monitoring.Portlet, requestStatus=SUCCESS, stopWatch=0:00:00.001, timeout=0, user=null}}, {displayName=Search, portletId=com_liferay_portal_search_web_portlet_SearchPortlet, requestType=RENDER, {attributes=null, companyId=20115, groupId=32711, description=null, duration=5, name=com_liferay_portal_search_web_portlet_SearchPortlet, namespace=com.liferay.monitoring.Portlet, requestStatus=SUCCESS, stopWatch=0:00:00.005, timeout=0, user=null}}, {displayName=Navigation, portletId=com_liferay_site_navigation_menu_web_portlet_SiteNavigationMenuPortlet, requestType=RENDER, {attributes=null, companyId=20115, groupId=32711, description=null, duration=6, name=com_liferay_site_navigation_menu_web_portlet_SiteNavigationMenuPortlet, namespace=com.liferay.monitoring.Portlet, requestStatus=SUCCESS, stopWatch=0:00:00.006, timeout=0, user=null}}, {referer=http://localhost:8443/group/elvis/~/control_panel/manage?p_p_id=com_liferay_layout_admin_web_portlet_GroupPagesPortlet&p_p_lifecycle=0&p_p_state=maximized&_com_liferay_layout_admin_web_portlet_GroupPagesPortlet_mvcPath=%2Fadd_layout.jsp&p_r_p_selPlid=0&_com_liferay_layout_admin_web_portlet_GroupPagesPortlet_groupId=32711&p_r_p_privateLayout=false&p_p_auth=EtbApZhS, remoteAddr=127.0.0.1, requestURL=http://localhost:8443/c/portal/status.jsp_display, statusCode=400, userAgent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36, {attributes=null, companyId=20115, groupId=32711, description=Portal Request, duration=151, name=/c/portal/status, namespace=com.liferay.monitoring.Portal, requestStatus=SUCCESS, stopWatch=0:00:00.151, timeout=-1, user=null}}, {referer=http://localhost:8443/group/elvis/~/control_panel/manage?p_p_id=com_liferay_layout_admin_web_portlet_GroupPagesPortlet&p_p_lifecycle=0&p_p_state=maximized&_com_liferay_layout_admin_web_portlet_GroupPagesPortlet_mvcPath=%2Fadd_layout.jsp&p_r_p_selPlid=0&_com_liferay_layout_admin_web_portlet_GroupPagesPortlet_groupId=32711&p_r_p_privateLayout=false&p_p_auth=EtbApZhS, remoteAddr=127.0.0.1, requestURL=, statusCode=400, userAgent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36, {attributes=null, companyId=20115, groupId=32711, description=null, duration=165, name=/c/portal/status, namespace=com.liferay.monitoring.Portal, requestStatus=SUCCESS, stopWatch=0:00:00.165, timeout=-1, user=null}}, {referer=http://localhost:8443/group/elvis/~/control_panel/manage?p_p_id=com_liferay_layout_admin_web_portlet_GroupPagesPortlet&p_p_lifecycle=0&p_p_state=maximized&_com_liferay_layout_admin_web_portlet_GroupPagesPortlet_mvcPath=%2Fadd_layout.jsp&p_r_p_selPlid=0&_com_liferay_layout_admin_web_portlet_GroupPagesPortlet_groupId=32711&p_r_p_privateLayout=false&p_p_auth=EtbApZhS, remoteAddr=127.0.0.1, requestURL=, statusCode=400, userAgent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36, {attributes=null, companyId=20115, groupId=32711, description=null, duration=242, name=/c/portal/layout, namespace=com.liferay.monitoring.Portal, requestStatus=SUCCESS, stopWatch=0:00:00.242, timeout=-1, user=null}}, {referer=http://localhost:8443/group/elvis/~/control_panel/manage?p_p_id=com_liferay_layout_admin_web_portlet_GroupPagesPortlet&p_p_lifecycle=0&p_p_state=maximized&_com_liferay_layout_admin_web_portlet_GroupPagesPortlet_mvcPath=%2Fadd_layout.jsp&p_r_p_selPlid=0&_com_liferay_layout_admin_web_portlet_GroupPagesPortlet_groupId=32711&p_r_p_privateLayout=false&p_p_auth=EtbApZhS, remoteAddr=127.0.0.1, requestURL=, statusCode=400, userAgent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36, {attributes=null, companyId=20115, groupId=32711, description=null, duration=253, name=/web/elvis/home, namespace=com.liferay.monitoring.Portal, requestStatus=SUCCESS, stopWatch=0:00:00.253, timeout=-1, user=null}}], values={defaultLocale=en_US, companyId=20115, groupId=0, principalName=20119, permissionChecker=com.liferay.portal.kernel.util.TransientValue@6131e6af, siteDefaultLocale=en_US, themeDisplayLocale=en_US}}
com.liferay.portal.kernel.messaging.MessageListenerException: java.lang.NullPointerException
	at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:32)
	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: java.lang.NullPointerException
	at com.liferay.portal.monitoring.internal.statistics.portlet.PortletStatistics.processDataSample(PortletStatistics.java:109)
	at com.liferay.portal.monitoring.internal.statistics.portlet.CompanyStatistics.processDataSample(CompanyStatistics.java:209)
	at com.liferay.portal.monitoring.internal.statistics.portlet.ServerStatistics.processDataSample(ServerStatistics.java:117)
	at com.liferay.portal.monitoring.internal.statistics.portlet.ServerStatistics.processDataSample(ServerStatistics.java:35)
	at com.liferay.portal.monitoring.internal.messaging.MonitoringMessageListener.processDataSample(MonitoringMessageListener.java:93)
	at com.liferay.portal.monitoring.internal.messaging.MonitoringMessageListener.doReceive(MonitoringMessageListener.java:120)
	at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:26)
	... 5 more
2018-07-09 21:46:45.197 INFO  [fileinstall-/Users/k11237/SGI_UpGrade_7.0/portal/osgi/modules][BundleStartStopLogger:38] STOPPED com.liferay.docs.guestbook.service_1.0.0 [1334]
2018-07-09 21:46:45.522 WARN  [Refresh Thread: Equinox Container: d01a9654-a680-0018-119b-810144b46c93][ServiceComponentLocalServiceImpl:617] Auto upgrading GB database to build number 8 is not supported for a production environment. Write an UpgradeStep to ensure data is upgraded correctly.
2018-07-09 21:46:45.897 INFO  [Refresh Thread: Equinox Container: d01a9654-a680-0018-119b-810144b46c93][BundleStartStopLogger:35] STARTED com.liferay.docs.guestbook.service_1.0.0 [1334]

Follow the following steps:

Step 1: run gradle task: clean

Step 2: deploy it again.