How to configure portlet to use com.vaadin...gwt.server.PortletApplicationC

Hi,

I’m new to portlet and Vaadin so I sorry in advance to stupid question.

My issue is tied to portlet context, my portlet implements com.vaadin.terminal.gwt.server.PortletApplicationContext2.PortletListener to listen some context changes.

When I try to subscribe portelt as listenener with the following code


PortletApplicationContext2 ctx = (PortletApplicationContext2)getContext();
ctx.addPortletListener(this, this);

I get this exception:


java.lang.ClassCastException: com.vaadin.terminal.gwt.server.WebApplicationContext cannot be cast to com.vaadin.terminal.gwt.server.PortletApplicationContext2

Can someone help me to resolve this issue?

Thanks a lot.

Rosario

You don’t configure the context used. If your portlet follows the Portlet 2.0 spec (JSR-286), the context is always a PortletApplicationContext2. If you are running a servlet, the context is always a WebApplicationContext. A Portlet 1.0 portlet (JSR-168) does have a servlet running “behind the scenes”.

See
the book
for more information. The critical bits in portlet.xml are something like:

  <portlet>
    <portlet-name>Portlet Example portlet</portlet-name>
    <display-name>Vaadin Portlet Example</display-name>
    <portlet-class>
      [b]
com.vaadin.terminal.gwt.server.ApplicationPortlet2
[/b]
    </portlet-class>
    <init-param>
      <name>application</name>
      <!-- The application class with package name. -->
      <value>com.example.myportlet.MyportletApplication</value>
    </init-param>

Hi Henri,

this is my portlet configuration and I use the same portlet-class.

I’ve also checked portlet.jar location and it is outside WEB-INF folder. I’m using Glassfish bundle to test my application.

Thanks a lot.