RE: Portlet Preferences are lost

4581076, modified 15 Years ago. Junior Member Posts: 34 Join Date: 2/8/10 Recent Posts
Hi all

I'm using this environment:
  • Liferay 4.4.2
  • Spring 2.0.6
  • MySQL (and once also on Postgress)


It's happening a very very strain thing
I built some portlet pages where i added some instances of my own spring based portlets
All worked pretty good
After some time (several month) i saw that all my spring portlets in the most of the pages lost their preferences. I reconfigured all the portlets and 2 days later i saw that they lost their preferences once again
I checked liferay DB and i didn't find the portlets preferences in the DB.
How can i solve the issue? What should i check to fix and solve it?

Regards,
Angelo
thumbnail
1586657, modified 15 Years ago. Regular Member Posts: 203 Join Date: 11/15/08 Recent Posts
Hi All,

Any update on this issue. Thanks.

Regards,
Srik
4581076, modified 15 Years ago. Junior Member Posts: 34 Join Date: 2/8/10 Recent Posts
Hi Srikanth

Just to know....are you having or did you have the same issue?
In affermative case.....may you tell me your environment?

Thank you.
Regards,
Angelo
thumbnail
1586657, modified 15 Years ago. Regular Member Posts: 203 Join Date: 11/15/08 Recent Posts
Hi Angelo,

I am using liferay tomcat 5.2.3 and sdk of the same version.

When i deploy the portlet onto my local server, the preferences are getting lost from there.

I am ending up with entering again the values there. Please let me know if you have any solution for this issue. Thanks.

Regards,
Srik
4581076, modified 15 Years ago. Junior Member Posts: 34 Join Date: 2/8/10 Recent Posts
Hi Srikanth

We are trying to investigate; if we solve we will advice you....if you solve before us...may you tell us too? emoticon

Thank you,
Angelo
thumbnail
1586657, modified 15 Years ago. Regular Member Posts: 203 Join Date: 11/15/08 Recent Posts
Sure Angelo.... emoticon
4581076, modified 15 Years ago. Junior Member Posts: 34 Join Date: 2/8/10 Recent Posts
Hi Srikanth
Sorry for being late but i was busy on other activities....
Anyway we did some debug and, at least on LF 4.4.2, we found in class com.liferay.portal.service.impl.PortletPreferencesLocalServiceImpl the following method

	public javax.portlet.PortletPreferences getPreferences(
			long companyId, long ownerId, int ownerType, long plid,
			String portletId, String defaultPreferences)
		throws PortalException, SystemException {

		Map prefsPool = PortletPreferencesLocalUtil.getPreferencesPool(
			ownerId, ownerType);

		String key = encodeKey(plid, portletId);

		PortletPreferencesImpl prefs =
			(PortletPreferencesImpl)prefsPool.get(key);

		if (prefs == null) {
			PortletPreferences portletPreferences = null;

			Portlet portlet = portletLocalService.getPortletById(
				companyId, portletId);

			try {
				portletPreferences =
					portletPreferencesPersistence.findByO_O_P_P(
						ownerId, ownerType, plid, portletId);
			}
			catch (NoSuchPortletPreferencesException nsppe) {
				System.out.println("NoSuchPortletPreferencesException");
				nsppe.printStackTrace();
				System.out.println("-------------------- fine stack ----------------------------------------");
				[color=#FA1010]long portletPreferencesId = counterLocalService.increment();

				portletPreferences = portletPreferencesPersistence.create(
					portletPreferencesId);

				portletPreferences.setOwnerId(ownerId);
				portletPreferences.setOwnerType(ownerType);
				portletPreferences.setPlid(plid);
				portletPreferences.setPortletId(portletId);

				if (Validator.isNull(defaultPreferences)) {
					if (portlet == null) {
						defaultPreferences = PortletImpl.DEFAULT_PREFERENCES;
					}
					else {
						defaultPreferences = portlet.getDefaultPreferences();
					}
				}

				portletPreferences.setPreferences(defaultPreferences);

				portletPreferencesPersistence.update(portletPreferences);
			}

			prefs = PortletPreferencesSerializer.fromXML(
				companyId, ownerId, ownerType, plid, portletId,
				portletPreferences.getPreferences());

			prefsPool.put(key, prefs);[/color]
		}

		return (PortletPreferencesImpl)prefs.clone();
	}


As you can see in the red block if something is wrong in recovering the portlet preferences the default preferencies are loaded, with no log message. We think this could be the problem. I don't know if this can be usefull for you too
We are going on in debuging

Regards,
Angelo
thumbnail
1586657, modified 15 Years ago. Regular Member Posts: 203 Join Date: 11/15/08 Recent Posts
Hi Angelo,

Thank you for providing the useful information. emoticon

If you get or find any solution or reason why these are getting lost, can you please let me too know. Thanks and waiting for you reply.

Regards,
Srik
Ervinas Marocka, modified 6 Years ago. Junior Member Posts: 31 Join Date: 10/8/18 Recent Posts
Any news?