Liferay user attributes


I am trying to integrate a Vaadin portlet into Liferay 5.2.3. Does anyone know how to get the name of the current user of Liferay in my Vaadin portlet ?


See e.g.
this thread
. In short, you need a portlet listener that stores the user somewhere in your application for the duration or a request, and use the portal specific APIs to get details about the user.

I understand I have to implement the class PortletListener first. But when I run it in Liferay (without doing anything else), there is a ClassCastException :
com.vaadin.terminal.gwt.server.ApplicationPortlet cannot be cast to javax.portlet.Portlet.

Here is my code :

package com.example.testvaadin1_0;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.EventRequest;
import javax.portlet.EventResponse;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;

import com.vaadin.Application;
import com.vaadin.terminal.gwt.server.PortletApplicationContext2.PortletListener;
import com.vaadin.ui.*;

public class Testvaadin1_0Application extends Application implements PortletListener {
	public void init() {
		Window mainWindow = new Window("Testvaadin1_0 Application");
		Label label = new Label("Hello Vaadin user");

	public void handleActionRequest(ActionRequest request,
			ActionResponse response, Window window) {
		// TODO Auto-generated method stub

	public void handleEventRequest(EventRequest request,
			EventResponse response, Window window) {
		// TODO Auto-generated method stub

	public void handleRenderRequest(RenderRequest request,
			RenderResponse response, Window window) {
		// TODO Auto-generated method stub

	public void handleResourceRequest(ResourceRequest request,
			ResourceResponse response, Window window) {
		// TODO Auto-generated method stub


This looks like a classloader issue. Are you using a shared Vaadin JAR on the portal or a separate one in the portlet?

Using a shared JAR might help - see e.g.
these instructions
the book
. Note especially the parts about copying the Vaadin JAR to “vaadin.jar” on the portal and the settings in .

Note also (as explained in the thread I referred to IIRC): If using Portlet 1.0 (ApplicationPortlet), you must use PortletApplicationContext.PortletListener. If using Portlet 2.0 (ApplicationPortlet2), you must use PortletApplicationContext2.PortletListener.

I have a separate vaadin.jar in my portlet but I use a portlet.jar (which contains javax.portlet…) in my portlet and another portlet.jar in Liferay.

Do you think it is the problem ?

Probably, if it is deployed with the portlet.

Try moving it to a directory that is not deployed (or not on the classpath on the portal, outside of WEB-INF/lib) and changing your development environment classpath to point to it.

Thank you very much Henri !!! You solved my problem :wink: