Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
BeanLocatorException in VM Template file in Liferay 7.2
Hi All, I am getting the exception for below code in VM Template
set ($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 ?

#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 ?
Hi,
Try below code
Try below code
$layoutLocalService = $serviceLocator.findService("com.liferay.portal.kernel.service.LayoutLocalService")
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™