BeanLocatorException in VM Template file in Liferay 7.2

thumbnail
Shiva Lingam K, modified 5 Years ago. New Member Posts: 18 Join Date: 5/9/18 Recent Posts
Hi All,          I am getting the exception for below code in VM Templateemoticonset ($layoutLocalService = $serviceLocator.findService("com.liferay.portal.service.LayoutLocalService"))
#set ($layoutId = $getterUtil.getLong($internallink.getData()))#set ($themeDisplay = $request.get('theme-display'))
#set ($currentPlid = $getterUtil.getLong($themeDisplay.get('plid')))
#set ($currentLayout = $layoutLocalService.getLayout($currentPlid))Exception:2020-09-14 09:25:38.456 ERROR [http-nio-8080-exec-1][ServiceLocator:50] com.liferay.portal.kernel.bean.BeanLocatorException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'com.liferay.portal.service.LayoutLocalService' available
com.liferay.portal.kernel.bean.BeanLocatorException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'com.liferay.portal.service.LayoutLocalService' available
        at com.liferay.portal.bean.BeanLocatorImpl.locate(BeanLocatorImpl.java:105)
        at com.liferay.portal.kernel.bean.PortalBeanLocatorUtil.locate(PortalBeanLocatorUtil.java:82)
        at com.liferay.portal.template.ServiceLocator.findService(ServiceLocator.java:45)

Any one tell me how to resolve this ?
thumbnail
Mohammed Yasin, modified 5 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts
Hi,
Try below code
$layoutLocalService = $serviceLocator.findService("com.liferay.portal.kernel.service.LayoutLocalService")

​​​​​​​