"PermissionChecker not initialised" in scheduler job
When writing a scheduler job in liferay, you don't have access to the the themeDisplay life in portlet methods. So you miss a lot of handy data.
If you like to call in your job code some of the local utility classes, you could become the following exception:
com.liferay.portal.security.auth.PrincipalException: PermissionChecker not initialized
This is because you don't have the permission to make that call. Just use the following code before your code and everything will be fine.
Company companyqq = CompanyLocalServiceUtil.getCompanyByWebId("myCompanyWebId");
Role adminRole = RoleLocalServiceUtil.getRole(companyqq.getCompanyId(),"Administrator");
List
PrincipalThreadLocal.setName(adminUsers.get(0).getUserId());
PermissionChecker permissionChecker =PermissionCheckerFactoryUtil.create(adminUsers.get(0), true);
PermissionThreadLocal.setPermissionChecker(permissionChecker);
myMethod();
source: here