Cast Exception when redeploying portlet to liferay

Hi all,

I’ve been struggling with a problem since I’ve upgraded to vaadin 6.6.0 (same with 6.6.1).

I’ve developed several portlets with no problem but now, when I redeploy any portlet from Eclipse, I get a ClassCastException :

com.vaadin.terminal.gwt.server.PortletApplicationContext2 cannot be cast to com.vaadin.terminal.gwt.server.PortletApplicationContext2


ERROR [jsp:154]
 java.lang.ClassCastException: com.vaadin.terminal.gwt.server.PortletApplicationContext2 cannot be cast to com.vaadin.terminal.gwt.server.PortletApplicationContext2
	at com.vaadin.terminal.gwt.server.PortletApplicationContext2.getApplicationContext(PortletApplicationContext2.java:122)
	at com.vaadin.terminal.gwt.server.AbstractApplicationPortlet.getApplicationContext(AbstractApplicationPortlet.java:1623)
	at com.vaadin.terminal.gwt.server.AbstractApplicationPortlet.getExistingApplication(AbstractApplicationPortlet.java:857)
	at com.vaadin.terminal.gwt.server.AbstractApplicationPortlet.findApplicationInstance(AbstractApplicationPortlet.java:790)
	at com.vaadin.terminal.gwt.server.AbstractApplicationPortlet.handleRequest(AbstractApplicationPortlet.java:370)
	at com.vaadin.terminal.gwt.server.AbstractApplicationPortlet.doDispatch(AbstractApplicationPortlet.java:724)
	at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
	at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:101)
	at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64)
	at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:92)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
	at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
	at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
	at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:638)
	at com.liferay.portlet.InvokerPortletImpl.invokeRender(InvokerPortletImpl.java:723)
	at com.liferay.portlet.InvokerPortletImpl.render(InvokerPortletImpl.java:425)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

It’s really annoying because the only way I manage to test my portlet is by restarting the server, which takes ages … And everything was working great when using vaadin 6.5.7.

I’ve made sure that I don’t have 2 vaadin.jar : I have one in liferay/WEBINF/lib/vaadin.jar and none in the deployed war

I’ve googled this but could not find any decent solution so I’m hoping that the vaadin experts on this forum will be able to help out.

Thanks a lot and have a nice day

Ben

Hi,

When you get a ClassCastException with something like your

“com.vaadin.terminal.gwt.server.PortletApplicationContext2 cannot be cast to com.vaadin.terminal.gwt.server.PortletApplicationContext2”

it really means that the class in question has been loaded by two different classloaders. So you most probably do have a second vaadin.jar hiding somewhere on the classpath. These can be a real pain to find sometimes. One good way to find the hiding jar file is to ask a colleague to search through the classpath with you. That always works for me.

HTH,
/Jonatan

Hi Ben,

Caused by: java.lang.ClassCastException: FirstPortlet cannot be cast to javax.portlet.Portlet, After Googling, it appears that deploying vaadin.jar is a mistake with path not found.

javax.portlet.Portlet is implemented by GenericPortlet, and only 1Portlet found Error inside other Portlet

2ERROR [jsp:154]
java.lang.ClassCastException: com.vaadin.terminal.gwt.server.PortletApplicationContext2 cannot be cast to com.vaadin.terminal.gwt.server.PortletApplicationContext2

I would suggest that you double check if you don’t have vaadin.jar (or another jar which contains Portlet) loaded twice somewhere. The possible locations depend on the container you are using.

Regards
Kevin Thomas
Attune Infocom Inc
http://www.attuneinfocom.com
Email : contact@attuneinfocom.com

Liferay Portlet

This problem seems to occur if you set <private-session-attributes>false</private-session-attributes> in liferay-portlet.xml.

It would be nice to get
session attributes shared
between
portlets
. I wrote
a ticket about this issue
.

As you probably saw, fixed for the next Vaadin release by recreating the Vaadin application context if it is not compatible with the current Vaadin classes e.g. after redeploy.