spring2.5 injected vaadin portlet2

i’am a chinese vaadin developer

I’m use spring to develop vaadin portlet, but get a exception when deploy this porlet ,

Caused by: java.lang.ClassCastException: com.vaadin.terminal.gwt.server.ApplicationPortlet2 cannot be cast to javax.portlet.Portlet
at com.liferay.portal.deploy.hot.PortletHotDeployListener.initPortlet(PortletHotDeployListener.java:445)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:250)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:127)
… 22 more

this is my vaadin application code
public class VaadintestApplication extends Application
implements java.io.Serializable
private Window viewWindow;
private Window editWindow;
private AreaServiceImpl areaServiceImpl;

public void init() {
	Window mainWindow = new Window("Vaadintest Application");
	SpringContextHelper helper=new SpringContextHelper(this);
	AreaDemo demo=new AreaDemo(areaServiceImpl);
	// url /?username=deng&pwd=123456
	mainWindow.addParameterHandler(new ParameterHandler(){

		public void handleParameters(Map<String, String[]> parameters) {
			// TODO Auto-generated method stub
		    Set<String> keysSet=parameters.keySet();
		    for(String key:keysSet)
		    	String[] values=parameters.get(key);
		    	for(String value:values)


this is springhelpclass

public class SpringContextHelper {

private ApplicationContext context;

public SpringContextHelper(Application application) {
	PortletContext portletContext = ((PortletApplicationContext2) application.getContext()).getPortletSession().getPortletContext();
	context = PortletApplicationContextUtils.getWebApplicationContext(portletContext);

	// ServletContext servletContext = ((ApplicationContext) application.getContext()).getHttpSession().getServletContext();
   // context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);

public Object getBean(final String beanRef) {
    return context.getBean(beanRef);


who can tell me how to solve this exception?

This looks very much like a classloader problem: your application server loads the classes Portlet and ApplicationPortlet2 with different (unrelated) classloader instances and the Class instances in the JVM are not compatible with each other.

One option that should help would be to deploy vaadin.jar on the portal as a shared JAR (in webapps/ROOT/WEB-INF/lib on Liferay) and refer to it in your liferay-plugin-package.properties on the portal-dependency-jars=… line instead of deploying it with your portlet. When using portlet 2.0, you need to deploy the themes and widgetsets on the portal anyway as described e.g.

You can also search the forum for other related threads.

Also, you should make sure you are not deploying the portlet API JAR with your application, but that would not seem to be a problem here.