Fórum

Model listener on a custom entity error

thumbnail
Ivano Carrara, modificado 12 Anos atrás.

Model listener on a custom entity error

Expert Postagens: 345 Data de Entrada: 03/07/05 Postagens Recentes
Hi all,

I tested a model listener on a Liferay's entity (User) and all is working fine. See the below code:

public class UserListener extends BaseModelListener<user>{
	private static Log _log = LogFactoryUtil.getLog(UserListener.class);

    @Override
    public void onAfterCreate(User user) throws ModelListenerException {
    	
    	_log.info("In onAfterCreate" + user.getUserId());
    	super.onAfterCreate(user);
    	
    }

    @Override
    public void onAfterUpdate(User user) throws ModelListenerException {
    	
    	_log.info("In onAfterUpdate" + user.getUserId());
        super.onAfterUpdate(user);
        
    }
    
}
</user>


BUT using the same logic on a custom entity in my custom portlet I got the below error:

10:52:50,737 ERROR [HotDeployUtil:112] com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering hook for o2-base-portlet
com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering hook for o2-base-portlet
at com.liferay.portal.kernel.deploy.hot.BaseHotDeployListener.throwHotDeployException(BaseHotDeployListener.java:45)
at com.liferay.portal.deploy.hot.HookHotDeployListener.invokeDeploy(HookHotDeployListener.java:221)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent(HotDeployUtil.java:109)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(HotDeployUtil.java:182)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:38)
at com.liferay.portal.kernel.servlet.PortletContextListener.doPortalInit(PortletContextListener.java:99)
at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:42)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:52)
at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:50)
at com.liferay.portal.kernel.servlet.PortletContextListener.contextInitialized(PortletContextListener.java:55)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1244)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1342)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:662)
Caused by: com.liferay.portal.kernel.bean.BeanLocatorException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'o2.base.service.persistence.OMUserDittaPersistence' is defined
at com.liferay.portal.bean.BeanLocatorImpl.locate(BeanLocatorImpl.java:59)
at com.liferay.portal.kernel.bean.PortalBeanLocatorUtil.locate(PortalBeanLocatorUtil.java:48)
at com.liferay.portal.deploy.hot.HookHotDeployListener.getPersistence(HookHotDeployListener.java:809)
at com.liferay.portal.deploy.hot.HookHotDeployListener.initModelListener(HookHotDeployListener.java:1120)
at com.liferay.portal.deploy.hot.HookHotDeployListener.initModelListeners(HookHotDeployListener.java:1151)
at com.liferay.portal.deploy.hot.HookHotDeployListener.doInvokeDeploy(HookHotDeployListener.java:461)
at com.liferay.portal.deploy.hot.HookHotDeployListener.invokeDeploy(HookHotDeployListener.java:218)
... 19 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'o2.base.service.persistence.OMUserDittaPersistence' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1083)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:274)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
at com.liferay.portal.bean.BeanLocatorImpl.doLocate(BeanLocatorImpl.java:105)
at com.liferay.portal.bean.BeanLocatorImpl.locate(BeanLocatorImpl.java:56)
... 25 more


Please, anyone can help me?

Thank you in advance,
Ivano C.
thumbnail
Sandeep Nair, modificado 12 Anos atrás.

RE: Model listener on a custom entity error

Liferay Legend Postagens: 1744 Data de Entrada: 06/11/08 Postagens Recentes
I think it may be a bug in liferay. Please check the following LPS and workaround

http://issues.liferay.com/browse/LPS-10988

Regards,
Sandeep
thumbnail
Ravi Kumar Gupta, modificado 12 Anos atrás.

RE: Model listener on a custom entity error

Liferay Legend Postagens: 1302 Data de Entrada: 24/06/09 Postagens Recentes
Are hooks/ext not meant for only liferay's existing code.. ??
thumbnail
Ivano Carrara, modificado 12 Anos atrás.

RE: Model listener on a custom entity error

Expert Postagens: 345 Data de Entrada: 03/07/05 Postagens Recentes
Hi Ravy,

No.... all entities (Liferay and not Liferay) built with Service Builder are usable with Model Listener...

Thank you,
Ivano C.
thumbnail
Ravi Kumar Gupta, modificado 12 Anos atrás.

RE: Model listener on a custom entity error

Liferay Legend Postagens: 1302 Data de Entrada: 24/06/09 Postagens Recentes
Thanks Ivano for the clarification.. thats gonna help me someday.. emoticon
thumbnail
Ivano Carrara, modificado 12 Anos atrás.

RE: Model listener on a custom entity error

Expert Postagens: 345 Data de Entrada: 03/07/05 Postagens Recentes
... of course the Model listeners over custom entities are still a dream until the http://issues.liferay.com/browse/LPS-10988 is not fixed :-) or some good boy / girl give us the fixed Ant file :-)
thumbnail
Sandeep Nair, modificado 12 Anos atrás.

RE: Model listener on a custom entity error

Liferay Legend Postagens: 1744 Data de Entrada: 06/11/08 Postagens Recentes
Can you replace the attached build-common-plugin.xml.

Note: I have just done as mentioned in LPS and havent actually checked if it works
thumbnail
Ivano Carrara, modificado 12 Anos atrás.

RE: Model listener on a custom entity error

Expert Postagens: 345 Data de Entrada: 03/07/05 Postagens Recentes
Thank you for the file...
I installed it in Liferay SDK, then I replaced the name of my service package as below:

<replace dir="${basedir}/docroot/WEB-INF/src/o2/base/service/persistence" includes="*PersistenceImpl.java" summary="yes"></replace>


... and rebuilt the services but the error is still the same:

Caused by: com.liferay.portal.kernel.bean.BeanLocatorException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'o2.base.service.persistence.OMUserDittaPersistence' is defined


Anyone used the modified build-common-plugin.xml as the workaround from http://issues.liferay.com/browse/LPS-10988 ?

Thank you in advance!

Ivano C.
thumbnail
clint barbosa, modificado 11 Anos atrás.

RE: Model listener on a custom entity error

New Member Postagens: 7 Data de Entrada: 23/08/12 Postagens Recentes
Hi All,

So what is the solution for this issue, I'm also encountering the same problem. THanks
thumbnail
David H Nebinger, modificado 11 Anos atrás.

RE: Model listener on a custom entity error

Liferay Legend Postagens: 14914 Data de Entrada: 02/09/06 Postagens Recentes
You cannot add a listener to a custom service plugin outside of that plugin project itself. The listener must be part of the same project.
thumbnail
clint barbosa, modificado 11 Anos atrás.

RE: Model listener on a custom entity error

New Member Postagens: 7 Data de Entrada: 23/08/12 Postagens Recentes
All the listeners and the service are in one project
Martin Wiegand, modificado 9 Anos atrás.

RE: Model listener on a custom entity error

New Member Postagens: 7 Data de Entrada: 08/03/11 Postagens Recentes
Hey guys,

we posted a solution for that in this thread:

https://www.liferay.com/de/community/forums/-/message_boards/view_message/41128768#_19_message_41125615

Regards,
Martin
thumbnail
Ivano Carrara, modificado 12 Anos atrás.

RE: Model listener on a custom entity error

Expert Postagens: 345 Data de Entrada: 03/07/05 Postagens Recentes
Thank you Sandeep!

I'm sure this is the solution, but... please could you attach here the modified Ant file, please?

Thank you in advance!

Ivano C.