Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Hubert Felber
No User exists with the primary key 0
3 giugno 2010 0.28
Risposta

Hubert Felber

Punteggio: Regular Member

Messaggi: 157

Data di Iscrizione: 23 novembre 2009

Messaggi recenti

Hi,
I am testing with trunk revision 54478 from 2.6.2010
On some pages (like "My Account) I get
1ERROR [IncludeTag] com.liferay.portal.NoSuchUserException: No User exists with the primary key 0

Reason:
We are using JAAS and are authenticating by screenname.
In this very case ("my account") Liferay internally stored the name in PrincipalBean as "administrator" which results in 0 when calling GetterUtil.getLong(name).

We defined an AutoLoginFilter where we overwrite getRemoteUser() to return the numerical userId from screenName to Liferay. But this seams to be not sufficient.
The filter has the following mappings:
1
2<url-pattern>/c/portal/protected</url-pattern>
3<url-pattern>/c/layout_management/update_page</url-pattern>

Questions:
  • Is AutoLoginFilter the correct method to ensure that Liferay gets the numerical UserId where ever it is needed? If not, what should I do?
  • Is there a rule on what url-pattern I have to map this autologin filter?
  • How would this work if the URL additionally contained the language like e.g. "/de/c/portal/proteced")? In the latter case I have to remove the language (de,en,it) programmatically from the URL in (overloaded) LoginAction to make Liferay display the page at all (only with JAAS enabled).

Thank you
Hubert
Hubert Felber
RE: No User exists with the primary key 0
3 giugno 2010 9.27
Risposta

Hubert Felber

Punteggio: Regular Member

Messaggi: 157

Data di Iscrizione: 23 novembre 2009

Messaggi recenti

Hi
In com.liferay.portlet.login.util.login() the j_remoteUser attribute is set which has the correct value.
In com.liferay.portal.servlet.MainServlet.getRemoteUser() Liferay calls request.getRemoteUser() and then sometimes receives the screen name. But the j_remoteUser attribute would have the correct value, but is not used when JAAS is enabled. If this would be used, it would not be necessary to establish filter to map remote screen name to Liferay internal userID.
What is the reason for this?
Thank you
Hubert
Jorge Ferrer
RE: No User exists with the primary key 0
15 giugno 2010 7.27
Risposta

Jorge Ferrer

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 2768

Data di Iscrizione: 31 agosto 2006

Messaggi recenti

Hi Hubert,

Is this something new in 6.0 or also happened in 5.2. If it's the latter I'd recommend you to create a JIRA ticket for it.
Hubert Felber
RE: No User exists with the primary key 0
21 giugno 2010 3.19
Risposta

Hubert Felber

Punteggio: Regular Member

Messaggi: 157

Data di Iscrizione: 23 novembre 2009

Messaggi recenti

Jorge Ferrer:
...create a JIRA ticket for it.
Hi Jorge, I did that, including a workaround that works for me.
Regards
Hubert
Jorge Ferrer
RE: No User exists with the primary key 0
21 giugno 2010 7.02
Risposta

Jorge Ferrer

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 2768

Data di Iscrizione: 31 agosto 2006

Messaggi recenti

Thanks Hubert,

Thanks for creating the tickets. We have many tickets open right now, many of which are not real issues so it's becoming very hard to distinguish those that are most worthy. We have a plan to fix this, but meanwhile, for this type of issues it's best if you also create a comment and (this is very important) link to the JIRA ticket.

I've taken a look at your proposed patch, but it seems all it does is log an error if the remoteUser is not a number. How does that fix the issue?
Hubert Felber
RE: No User exists with the primary key 0
21 giugno 2010 7.39
Risposta

Hubert Felber

Punteggio: Regular Member

Messaggi: 157

Data di Iscrizione: 23 novembre 2009

Messaggi recenti

Jorge Ferrer:
How does that fix the issue?

Jorge,

If it is not a number it cannot be a valid Liferay user id which is numeric only.
This means that getRemoteUser() returned the screenname used by the user to sign in.
And it also means that I don't have a filter set for this URL (therefore the error message).
In this case I take the remoteuser from the "j_remoteuser" session attribute.
1remoteUser = (String) request.getSession().getAttribute("j_remoteuser");

The "j_remoteuser" is set by com.liferay.portlet.login.util.LoginUtil.
If JAAS is enabled, this attribute remains in the session while it is removed if JAAS is not configured. This works for us because we don't have AllNumericUserNames.
Actually I don't see a reason why not to use always an attribute like this to get the Liferay internal user id.

Hubert
Michael Oliver
RE: No User exists with the primary key 0
18 giugno 2014 17.27
Risposta

Michael Oliver

Punteggio: Junior Member

Messaggi: 66

Data di Iscrizione: 19 aprile 2012

Messaggi recenti

While this may not be related, I am getting the same exception when trying to update an organization via /api/jsonws/

1http://localhost:8080/api/jsonws/organization/update-organization/organization-id/12501/parent-organization-id/0/name/abcnew2a/type/regular-organization/recursable/true/region-id/0/country-id/0/status-id/12017/comments/updated+Through+Jsonws+again/site/false
2resultJson = {"exception":"No User exists with the primary key 0"}


I am logged in as the same admin user that I used to create the organization in the first place, and here I am updating the organization name by appending the 'a' and changing the comments.