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


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.


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”.

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

    <portlet-name>Portlet Example portlet</portlet-name>
    <display-name>Vaadin Portlet Example</display-name>
      <!-- The application class with package name. -->

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.