I want to get the current user in my CAF portlet.

I create this kink of Java code

public getPerson()  {
	if (person == null) {
		person = new;
	resolveDataBinding(PERSON_PROPERTY_BINDINGS, person, "person", false, false);
	return person;

This code supply me a provider to access to user information called person.

And when I assign Principal ID in parameter of my WS which managed right, the bahviour is correct.

But when I try with other user than my self (who am an Administrator) or Administrator, I have a JavaNullPointerException.
I guess the person Object is not filled and I can not assign Person ID with parameter of my web service.

The fact is in My Webmethod server I deny access to every objects for anyone (except Administrator) except the portlet I created.
I guess to access to Provider which give information about user, I need user have right to see it but I don’t know where is it.

Are you able to shared the stacktrace that shows where the NPE came from?

If all you need is the username, you can probably just get the remote user from the current http request without using any MWS specific APIs.

For example, from the JSF external context object like this:

	public String getWhoAmI() {
		return getFacesContext().getExternalContext().getRemoteUser();

Or more simply directly using an expression that resolves to the same without writing any custom java code with a binding expression like this:


Hi Eric,
Thx for your reply,
Your function works.