Deploying my first Vaadin portlet to Liferay

Hello Everyone,

I was hoping to find a little help with deploying my first Vaadin portlet to Liferay.
I’m currently using Liferay 6.1, Vaadin 7.0.2, Eclipse Indigo, and the latest IDE tools and Vaadin plugins for Eclipse.
I am also using the latest version of Liferay bundled with Tomcat which is successfully running on my local machine.

I have successfully created and deployed a Vaadin serverlet project in Eclipse which is accessible via http://localhost:8080/vaadin_project_01
However, no content is loaded whenever I try to deploy a Generic Portlet (2.0) project to Eclipse.

When accessing http://localhost:8080/vaadin_portlet_01 I receive a 404 error.

I have used Ivy to resolve all necessary dependencies, compiled the Vaadin Widgets, chosen ‘Run on Server’ from the project context menu, and I can see that the the portlet files have been uploaded to the server. The portlet project itself hasn’t been edited since creation and I can see from the web.xml file that the so I’m expecting to see a simple button labelled ‘Click Me’ which prints a message to the screen when clicked.

The portlet is loaded into Liferay when deploying the application as a WAR file and I have the option to add the portlet to the to a page however, when I reload the page to view the new portlet I receive the error [404_jsp:?] /html/VAADIN/vaadinBootstrap.js as the ROOT/html/VAADIN/ folder on tomcat only has ‘themes’ and ‘widgets’ folders.

Update:
Updating my web.xml config to include a serverlet-mapping to “/*” allows me to view the portlet from http://localhost:8080/vaadin_portlet_01 however I am still receiving the “Failed to load bootstrap javascript” error when trying to view the content in a portlet.

Any help on this would be fantastic.

Thanks!

Did you get any answer for this frustrating problem

There are a few steps you need to take to get Liferay on Vaadin 7, since it still ships with Vaadin 6 integrated. Take a look at the wiki article at
https://vaadin.com/wiki/-/wiki/Main/Integrating%20Vaadin%207%20with%20Liferay

Hope that helps

Thanks Marcus! That works perfectly.

I’m onto my next problem now which is how to get the current user from Liferay?
I’ve seen many examples on how to do this with vaadin 6 however I cannot find out how to do it using vaadin 7.

I’m looking at implementing PortletListener and using the handleRenderRequest method to get the necessary PortletRequest object for PortalUtil.getUser …
Would this be the correct method? Or would it be best if I created a new topic and requested help there?

All the best,
Andrew

You can use e.g. VaadinService.getCurrentRequest() to get the VaadinPortletRequest and VaadinPortletService.getCurrentPortletRequest() to get the underlying PortletRequest.

Value of VaadinService.getCurrentRequest() is instance of VaadinServletRequest when app is executed as servlet and that is instance of VaadinPortletRequest when app is executed as portlet.

All user data can be got with PortalUtil.getUser((VaadinPortletRequest)VaadinService.getCurrentRequest()), this gets an object that implements User interface.

Dependencies like these (if you use Maven) are required in order to this code compiles:

    <dependency>
        <groupId>com.liferay.portal</groupId>
        <artifactId>portal-service</artifactId>
        <version>6.1.0</version>
    </dependency>
    <dependency>
        <groupId>javax.portlet</groupId>
        <artifactId>portlet-api</artifactId>
        <version>2.0</version>
    </dependency>

Both JARs must be removed from Liferay Tomcat deployment to avoid runtime errors.

Adding provided to the dependencies makes them available at compile time but not deployed.

Oh, thanks, I didn’t know that, I’m not a Maven expert. Thank you very much.

Please check this
https://vaadin.com/forum#!/thread/13176449