<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>PrincipalThreadLocal.getUserId() is 0 for Icefaces (1.8.2) portlets</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=87782724" />
  <subtitle>PrincipalThreadLocal.getUserId() is 0 for Icefaces (1.8.2) portlets</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=87782724</id>
  <updated>2026-04-04T02:25:27Z</updated>
  <dc:date>2026-04-04T02:25:27Z</dc:date>
  <entry>
    <title>RE: PrincipalThreadLocal.getUserId() is 0 for Icefaces (1.8.2) portlets</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=87839549" />
    <author>
      <name>Neil Griffin</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=87839549</id>
    <updated>2017-03-31T16:29:32Z</updated>
    <published>2017-03-31T16:29:32Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hi Parkash,&lt;br&gt;&lt;br&gt;We have an &lt;a href="https://github.com/liferay/liferay-faces-bridge-impl/blob/2.x/demo/icefaces-applicant-portlet"&gt;ICEfaces 1.8 version of our jsf-applicant-portlet demo&lt;/a&gt; available. I recommend you study the source code in order to learn how to read/store portlet preferences.&lt;br&gt;&lt;br&gt;One thing I'd like to mention is that the &lt;a href="https://github.com/liferay/liferay-faces-bridge-impl/blob/2.x/demo/icefaces-applicant-portlet/pom.xml"&gt;pom.xml&lt;/a&gt; descriptor contains an extra dependency that helps add JSR 329 style EL keywords (such as &lt;span style="font-family: Courier New"&gt;mutablePortletPreferencesValues&lt;/span&gt;), even though ICEfaces 1.8 does not utilize the JSR 329 bridge standard:&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;dependency&amp;gt;
	&amp;lt;groupid&amp;gt;com.liferay.faces&amp;lt;/groupid&amp;gt;
	&amp;lt;artifactid&amp;gt;com.liferay.faces.bridge.ice&amp;lt;/artifactid&amp;gt;
	&amp;lt;version&amp;gt;2.0.0&amp;lt;/version&amp;gt;
&amp;lt;/dependency&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;Kind Regards,&lt;br&gt;&lt;br&gt;Neil&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Neil Griffin</dc:creator>
    <dc:date>2017-03-31T16:29:32Z</dc:date>
  </entry>
  <entry>
    <title>RE: PrincipalThreadLocal.getUserId() is 0 for Icefaces (1.8.2) portlets</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=87816062" />
    <author>
      <name>Parkash Kumar</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=87816062</id>
    <updated>2017-03-31T07:10:40Z</updated>
    <published>2017-03-31T07:10:40Z</published>
    <summary type="html">Thank you very much &lt;strong&gt;Neil&lt;/strong&gt; for your response.&lt;br /&gt;&lt;br /&gt;Yes, we have been using &lt;strong&gt;Liferay 6.2&lt;/strong&gt; and sorry we can&amp;#39;t upgrade icefaces as we are totally moving to primefaces for newer development. Though, we have to provide support for our older version.&lt;br /&gt;&lt;br /&gt;Well, I would like to share my investigation:&lt;br /&gt;PrincipalThreadLocal.getUserId() is 0 in store() method of PortletPreferencesImpl when saving preferences any icefaces based portlet.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Reason:&lt;/strong&gt;&lt;br /&gt;For each request, com.liferay.portal.servlet.MainServlet.service:457 &amp;gt; setPrincipal:1305 of Liferay is responsible to set userId in PrincipalThreadLocal. However, for icefaces portlets Liferay&amp;#39;s MainServlet does not get invoked, as there is exactly same named servlet (com.icesoft.faces.webapp.http.servlet.MainServlet) in icefaces jar, which gets invoked instead.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Traces:&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Liferay OTB&amp;#39;s / Primefaces portlets:&lt;/em&gt;&lt;br /&gt;at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:523)&lt;br /&gt;at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Icefaces portlets:&lt;/em&gt;&lt;br /&gt;at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:204)&lt;br /&gt;at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)</summary>
    <dc:creator>Parkash Kumar</dc:creator>
    <dc:date>2017-03-31T07:10:40Z</dc:date>
  </entry>
  <entry>
    <title>RE: PrincipalThreadLocal.getUserId() is 0 for Icefaces (1.8.2) portlets</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=87793629" />
    <author>
      <name>Neil Griffin</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=87793629</id>
    <updated>2017-03-30T15:28:01Z</updated>
    <published>2017-03-30T15:28:01Z</published>
    <summary type="html">Hi Parkash,&lt;br /&gt;&lt;br /&gt;What version of Liferay Portal are you using?&lt;br /&gt;&lt;br /&gt;ICEfaces 1.8 is an outdated version of ICEfaces that requires JSF 1.2 (circa 2008) and is only supported up through Liferay Portal 6.2.&lt;br /&gt;&lt;br /&gt;I think the problem you are encountering is caused by the fact that ICEfaces 1.8 only participates in the portlet lifecycle during the initial HTTP GET of the portal page. After that, all XHR requests go through the ICEfaces servlet, rather that a portlet lifecycle ResourceRequest. That would explain why Liferay&amp;#39;s PrincipalThreadLocal is not working.&lt;br /&gt;&lt;br /&gt;Are you able to upgrade to a more modern version of ICEfaces such as 4.1 or 4.2? Similar to PrimeFaces 5/6, those versions of ICEfaces utilize the portlet lifecycle via Liferay Faces Bridge.&lt;br /&gt;&lt;br /&gt;Kind Regards,&lt;br /&gt;&lt;br /&gt;Neil</summary>
    <dc:creator>Neil Griffin</dc:creator>
    <dc:date>2017-03-30T15:28:01Z</dc:date>
  </entry>
  <entry>
    <title>PrincipalThreadLocal.getUserId() is 0 for Icefaces (1.8.2) portlets</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=87782723" />
    <author>
      <name>Parkash Kumar</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=87782723</id>
    <updated>2017-03-30T11:18:55Z</updated>
    <published>2017-03-30T11:18:55Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hi,&lt;br&gt;&lt;br&gt;I am basically implementing logger on the generic actions like saving portlet's preferences in store method of &lt;pre&gt;&lt;code&gt;PortletPreferencesImpl&lt;/code&gt;&lt;/pre&gt;. Here I am calling &lt;pre&gt;&lt;code&gt;PrincipalThreadLocal.getUserId()&lt;/code&gt;&lt;/pre&gt; to get user information. Everything is fine for the &lt;strong&gt;Liferay OTB's&lt;/strong&gt; portlets and for &lt;strong&gt;Primefaces 5.2&lt;/strong&gt; portlets but when I am saving preferences of &lt;strong&gt;Icefaces (1.8.2)&lt;/strong&gt; portlet, I am always getting 0 from &lt;pre&gt;&lt;code&gt;PrincipalThreadLocal.getUserId()&lt;/code&gt;&lt;/pre&gt;.&lt;br&gt;&lt;br&gt;Why is this strange behavior?&lt;br&gt;Please share your valuable feedback.&lt;br&gt;&lt;br&gt;&lt;strong&gt;Cross Posted:&lt;/strong&gt; http://stackoverflow.com/questions/43116457/principalthreadlocal-getuserid-is-0-for-icefaces-1-8-2-portlets&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Parkash Kumar</dc:creator>
    <dc:date>2017-03-30T11:18:55Z</dc:date>
  </entry>
</feed>
