Message Boards

Database cleanup assistance

thumbnail
David Harding, modified 9 Years ago.

Database cleanup assistance

New Member Posts: 3 Join Date: 10/9/13 Recent Posts
We are seeing the following error when the Trash task runs:

java.lang.NullPointerException
at com.liferay.portlet.trash.util.TrashImpl.getMaxAge(TrashImpl.java:225)
at com.liferay.portlet.trash.util.TrashUtil.getMaxAge(TrashUtil.java:80)
at com.liferay.portlet.trash.service.impl.TrashEntryLocalServiceImpl.getMaxAge(TrashEntryLocalServiceImpl.java:391)
......

We know that in the past some direct manipulation was done against the database (running Liferay 5.2.3), we do not know exactly what they did as it pre-dates the current team. The data has since been migrated to Liferay 6.2 EE.

The stack trace is because there is a Group record with a classPk that points to a Layout record that doesn't exist.
Does anyone have any suggestions for how to go about cleaning this up?
thumbnail
David H Nebinger, modified 9 Years ago.

RE: Database cleanup assistance

Liferay Legend Posts: 14916 Join Date: 9/2/06 Recent Posts
Fix the invalid layout record.

Basically the line of code is this:

		int trashEntriesMaxAge = PrefsPropsUtil.getInteger(
			group.getCompanyId(), PropsKeys.TRASH_ENTRIES_MAX_AGE,
			PropsValues.TRASH_ENTRIES_MAX_AGE);


Not sure what the NPE is coming from, group can't be null or it would have triggered an NPE somewhere else, PropsKeys.TRASH_ENTRIES_MAX_AGE is a string constant, the PropsValues one is pulled from the properties, but it uses code which is typically hardened against NPEs.
thumbnail
David Harding, modified 9 Years ago.

RE: Database cleanup assistance

New Member Posts: 3 Join Date: 10/9/13 Recent Posts
Thank you for the quick response.

This line:
group = group.getParentGroup();
is where the group ends up null.
This is caused by the parentGroupId of the original group being set to 0. This happened when the migration process was unable to find the missing layout.


		if (group.isLayout()) {
			group = group.getParentGroup();
		}

		int trashEntriesMaxAge = PrefsPropsUtil.getInteger(
			group.getCompanyId(), PropsKeys.TRASH_ENTRIES_MAX_AGE,
			PropsValues.TRASH_ENTRIES_MAX_AGE);