In liferay, I am trying to access the role data available in the database using the API.
I am using the com.liferay.portal.service.RoleLocalServiceUtil class to access Role's. Below is my code:
Role role = RoleLocalServiceUtil.getRole(10138);
ans = ans+role.getName()+","+role.getRoleId();
Role by Id 10138 exists in the database.
But the above throws the below exception: com.liferay.portal.kernel.bean.BeanLocatorException: BeanLocator has not been set com.liferay.portal.kernel.bean.PortalBeanLocatorUtil.locate(PortalBeanLocatorUtil.java:33) com.liferay.portal.service.RoleLocalServiceUtil.getService(RoleLocalServiceUtil.java:446) com.liferay.portal.service.RoleLocalServiceUtil.getRole(RoleLocalServiceUtil.java:166) com.bl.retail.controller.KPIController.changeAccess(KPIController.java:70) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ..........
How do I set the BeanLocator? I have spent so much stupid time on it, please help!
PS: The above code is from a seperate servlet running on the same liferay server.