RE: Unable to add address data in address table using ContactModelListener

thumbnail
Rahul Panchivala, modified 6 Years ago. New Member Posts: 3 Join Date: 4/30/19 Recent Posts
Hi Guys,

I am developing ContactModelListener, in which i am trying to add data into address table using onBeforeCreate() event and onAfterCreate() event , but after trying both event listener method one after another, data is not storing in address table, also there is no exception occurs during method execution, I have attached code, please help.

Environment : Liferay 7.1 CE GA2
thumbnail
David H Nebinger, modified 6 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Hmm, are you sure the component is even running?

Also, I cringe when I see "e.printStackTrace()" in code since you have no idea where it might actually go. It is so easy to instantiate a logger and using it guarantees where it will go, so why not just do it right from the outset?
thumbnail
Rahul Panchivala, modified 6 Years ago. New Member Posts: 3 Join Date: 4/30/19 Recent Posts
Hi David,

I have done changes as per your suggestion but i am not getting success and also i have checked that component is running PFA.
thumbnail
Gnaniyar Zubair, modified 6 Years ago. Liferay Master Posts: 724 Join Date: 12/19/07 Recent Posts
Hi Rahul,

Try log inside onAfterCreate or onBeforeCreate before the service triggers and after.

​​​​​​​
thumbnail
Rahul Panchivala, modified 6 Years ago. New Member Posts: 3 Join Date: 4/30/19 Recent Posts
Hi Zubair,

Actually i have debug code line by line and code is working without any exception, but after service execution(_addressLocalService.addAddress(address);) when i am going to check data in address table, data is not there.
thumbnail
Amos Fong, modified 6 Years ago. Liferay Legend Posts: 2047 Join Date: 10/7/08 Recent Posts
Does the contact get added to the DB? Can you check if the current transaction is read-only (eg triggered by a localService.getXMethod())?