I have implemented a functional Liferay service using service builder and I want to call a method on the -LocalServiceUtil
class just as soon as I possibly can. This is a task I wish to perform when the service starts and also when the service is redeployed.
Even though all the methods on the -LocalServiceUtil
class are static, they will throw a BeanLocatorException
if they are called too soon.
com.liferay.portal.kernel.bean.BeanLocatorException: BeanLocator has not been set for servlet context portal-navigation-impl
Is there any way to call a method on the -LocalServiceImpl
instance or otherwise so that I can do this?
Thank you
As you speak about the initialization order: I'm not 100% sure about this, but I'd write a startup action. This gets run everytime a hook (or plugin) starts up - including a redeploy. Sounds like what you want - and if the initialization order works, this is your solution.
Otherwise: Create a separate hook that's dependent on the one that you're currently using. That will be restarted as well, but only run once the hook providing the *-LocalService did already start up. (dependency is declared in
liferay-plugin-package.properties
, with the keyrequired-deployment-context
- this is from memory - somebody correct me if I'm wrong.)