Vaadin Portlet 2.0 Project in IBM's WebSphere Portal

Hi,

I am currently evaluating the vaadin technology for a small Portlet project.

Portalserver: IBM’s WebSphere Portal

I used the Eclipse plug for generating a HelloWort Projekt (Portlet v. 1.0) and everything works just fine. I could install it and run.

But, if I generate the same project with Portlet v2.0, it doesn’t start up with the error message

UIDL could not be read from server. Check servlets mappings. Error code: 404

Any idea where the problem could be? Thx

I compared the portlet.xml files, and the only diference is

<portlet-class>com.vaadin.terminal.gwt.server.ApplicationPortlet2</portlet-class>
        <init-param>
            <name>application</name>
            <value>com.example.portletv2.Portletv2Application</value>
        </init-param>
<servlet>
  	<servlet-name>Portletv2 Application</servlet-name>
  	<servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
  	<init-param>
  		<description>
  		Vaadin application class to start</description>
  		<param-name>application</param-name>
  		<param-value>com.example.portletv2.Portletv2Application</param-value>
  	</init-param>
  </servlet>
  <servlet-mapping>
  	<servlet-name>Portletv2 Application</servlet-name>
  	<url-pattern>/Portletv2ApplicationServlet/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
  	<servlet-name>Portletv2 Application</servlet-name>
  	<url-pattern>/VAADIN/*</url-pattern>
  </servlet-mapping>

that class is ApplicationPortlet2 and the value is now a package (no URI) and that’s correct, according to the description in Vaadin book.

You’ve probably seen this article about Vaadin and WebSphere but just in case it had gone by:
Developing potlets for IBM WebSphere Portal 6.1

Somehow, it seems the portlet class does not receive the requests from the client side engine. Maybe the requests point to the wrong location in this case.

The configuration parameters on the HTML page generated by the portlet could provide some clues - these can be seen e.g. with FireBug, the interesting part is the javascript block that sets up the variable vaadin.vaadinConfigurations . These parameters tell, among other things, where the client side engine should send various requests.

Note also that in a portlet 2.0 project, no servlet is really needed if you serve the resources statically - a web.xml file is generated to make it easier to test the application as a servlet, and potentially to serve resources.

You could put the VAADIN folder in a shared (preferably statically served) directory on the portal, and set up the path to it. On portals other than Liferay, this is looked up in the context property “vaadin.resources.path”, but I don’t know how to configure than on WebSphere. If necessary, you could even override AbstractApplicationPortlet.getPortalProperty() to handle this case. If the servlet is used to serve the resources and does not cause any conflicts, you could make it only serve /VAADIN .

Thx for help !!

It was my fault, I used Vaadin Portlet V1 and Vaadin Portlet V2 on the same page and that seems to be the problem, If I stick to the same version per portal page there is no problem…

Ernst, could you please share the example? I have been trying to get vaadin to work as Portlet 2.0 in Websphere portal but can’t get it to work. It just displays an empty portlet…

You can get a Vaadin JSR 286 portlet to run on WebSphere by completing these tasks (I tested on WPS 7.0):

  • create a new class that extends com.vaadin.terminal.gwt.server.ApplicationPortlet2 (example attached)
  • edit the portlet.xml (use your new class, apply the widgetset, set your theme)

In the portlet class I had to overwrite getStaticFilesLocation(PortletRequest request) to let vaadin find the widget resources. The default (/html) will work for Liferay but not for WPS.

The getThemeURI Method was overwritten, because Vaadin keeps trying to load the default theme “Reindeer” instead of my custom theme. I configured the theme as a portlet init parameter in the portlet.xml file.

The portlet class:

public class VaadinJSR286Portlet extends ApplicationPortlet2 {

	private static final Logger LOG = LoggerFactory.getLogger(VaadinJSR286Portlet.class);
	private boolean ibmWPS = false;
	
	public VaadinJSR286Portlet() {
		try {
			Class.forName("com.ibm.portal.portlet.Constants");
			ibmWPS = true;
		} catch (ClassNotFoundException e) { }
	}
	
	@Override
	protected String getStaticFilesLocation(PortletRequest request) {
		String location = super.getStaticFilesLocation(request);
		if (ibmWPS) {
			location = request.getContextPath();
		}
		return location;
	}

	@Override
	protected String getThemeURI(String themeName, PortletRequest request) {
		String themeURI = super.getThemeURI(themeName, request);
		if (ibmWPS) {
			String theme = getPortletConfig().getInitParameter("THEME_NAME");
			themeURI = request.getContextPath() + "/VAADIN/themes/" + theme;
		}
		LOG.debug("themeURI {} theme name {}", themeURI, themeName);
		return themeURI;
	}

	public boolean isIbmWPS() {
		return ibmWPS;
	}
}

The portlet.xml file for a JSR 286 portlet:


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<portlet-app
  xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  version="2.0"
  xsi:schemaLocation=
    "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd
     http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
	
	 <portlet>
	 	<portlet-name>My nice Portlet</portlet-name>
                <display-name>My niche Portlet Application</display-name>
        
<!-- 		<portlet-class>com.vaadin.terminal.gwt.server.ApplicationPortlet2</portlet-class> -->
		<portlet-class>de.something.something.VaadinJSR286Portlet</portlet-class>
		<init-param>
			<name>application</name>
			<value>de.something.something.MyVaadinApplication</value>
		</init-param>
		<init-param>
			<description>Application widgetset</description>
			<name>widgetset</name>
			<value>de.something.something.widgetset.MyCustomWidgetset</value>
		</init-param>
		<init-param>
			<description>Application Theme</description>
			<name>THEME_NAME</name>
			<value>custom-runo</value>
		</init-param>
		
        <supports>
            <mime-type>text/html</mime-type>
            <portlet-mode>view</portlet-mode>
            <portlet-mode>edit</portlet-mode>
            <portlet-mode>help</portlet-mode>
        </supports> 
        
        <portlet-info>
            <title>My working Application</title>
            <short-title>My really working Application</short-title>
		</portlet-info>
	 </portlet>	 
</portlet-app>