Obtaining reference to Logged in User object of Liferay

Hi experts,

I’m working on Liferay 6.0.6 and Vaadin 6.6.4 since last week.
I followed many posts here on this topic and wrote my implementation but still unable to obtain refernce to Logged in User object.
My Application class implements PortletRequestListener as well as PortletListener.
Following is the relevent code:

@Override
	public void onRequestStart(PortletRequest request, PortletResponse response) {
		try {
				User user = PortalUtil.getUser(request);
				setUser(user);
				if (request.getRemoteUser() != null)
					String remoteUser = request.getRemoteUser();
			} catch (PortalException pe) {
				// TODO Auto-generated catch block
				pe.printStackTrace();
			} catch (SystemException se) {
				// TODO Auto-generated catch block
				se.printStackTrace();
			}
		}

And

@Override
	public void handleActionRequest(ActionRequest request,
			ActionResponse response, Window window) {
		User user = null;
		try {
			user = PortalUtil.getUser(request);
			Map uinfo = (Map) request.getAttribute(PortletRequest.USER_INFO);
			int userId = Integer.valueOf(uinfo.get("liferay.user.id").toString());
			int companyId = Integer.valueOf(uinfo.get("liferay.company.id").toString());
			User liferayUser = UserLocalServiceUtil.getUserById(userId);
			user = (user != null ? user : liferayUser);
			setUser(user);// setting user to Application
		} catch (PortalException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SystemException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

The strange thing is when I did eclipse remote debug, control doesn’t even pass through any of these methods except init() method of Application class.
What possiblly going wrong here?

Thanks and Regards,
Shantanu

It turned out to be portlet.xml issue.
I have created maven project with Vaadin archetype but portlet.xml was not defined.
And .war has auto generated portlet.xml has following entry


<portlet>
	<portlet-name>MyPortlet</portlet-name>
	<portlet-class>[color=#ea0e0e]
com.liferay.util.bridges.wai.WAIPortlet
[/color]</portlet-class>
    <init-param>
		<name>[color=#ea0e0e]
wai.connector.iframe.height.default
[/color]</name>
		<value>[color=#ea0e0e]
500
[/color]</value>
	</init-param>
	.
	.
</portlet>		

which actually should be


<portlet>
	<portlet-name>MyPortlet</portlet-name>
	<portlet-class>[color=#0d228e]
com.vaadin.terminal.gwt.server.ApplicationPortlet2
[/color]</portlet-class>
	<init-param>
		<name>[color=#0d228e]
application
[/color]</name>
		<!-- The application class with package name. -->
		<value>[color=#0d228e]
com.myCompany.portlet.MyPortletApplication
[/color]</value>
	</init-param>
	.
	.
</portlet>			

I made those changes and copied the portlet.xml into WEB-INF inside my project structure so that it’s not generated again.
Now, the same code in first post works perfectly.
Don’t know if this is the way it should be done. Experts please comment.

Thanks and Regards,
Shantanu

There is no official Maven archetype for a Vaadin portlet, and Liferay does autogenerate all kinds of things in the portlet and servlet configuration at deployment time.

Maybe there will be such an archetype in the future (see
#4260
).