I'm trying to deploy my application on jboss-portal-2.7.2, and it is giving me the following error:
04:17:23,879 INFO [DispatcherPortlet] FrameworkPortlet 'my_portlet': initialization started
04:17:23,882 ERROR [LifeCycle] Cannot start object
org.jboss.portal.portlet.container.PortletInitializationException: The portlet my_portlet threw an error during init
at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.start(PortletContainerImpl.java:292)
at org.jboss.portal.portlet.impl.container.PortletContainerLifeCycle.invokeStart(PortletContainerLifeCycle.java:76)
at org.jboss.portal.portlet.impl.container.LifeCycle.managedStart(LifeCycle.java:92)
at org.jboss.portal.portlet.impl.container.PortletApplicationLifeCycle.startDependents(PortletApplicationLifeCycle.java:351)
...
at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:610)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
Caused by: java.lang.NoSuchMethodError: org.springframework.web.portlet.context.ConfigurablePortletApplicationContext.setId(Ljava/lang/String;)V
at org.springframework.web.portlet.FrameworkPortlet.createPortletApplicationContext(FrameworkPortlet.java:345)
at org.springframework.web.portlet.FrameworkPortlet.initPortletApplicationContext(FrameworkPortlet.java:294)
at org.springframework.web.portlet.FrameworkPortlet.initPortletBean(FrameworkPortlet.java:268)
at org.springframework.web.portlet.GenericPortletBean.init(GenericPortletBean.java:116)
at javax.portlet.GenericPortlet.init(GenericPortlet.java:107)
at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.initPortlet(PortletContainerImpl.java:417)
at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.start(PortletContainerImpl.java:256)
... 76 more
Does anyone know how to fix this?
MainController:
package myportlet.spring.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.portlet.bind.annotation.RenderMapping;
import org.apache.commons.lang.StringUtils;
import javax.portlet.PortletPreferences;
import javax.portlet.PortletRequest;
import javax.portlet.PortletSession;
import java.util.LinkedList;
import java.util.List;
@RequestMapping(value = "VIEW")
@Controller(value = "mainController")
public class MainController {
@RenderMapping
public String init(@RequestParam(value = "key", required = false) String key, Model model, PortletRequest request) throws Exception {
PortletSession session = request.getPortletSession();
/* Get Key from Portlet Preferences */
PortletPreferences preferences = request.getPreferences();
String preferencesKey = preferences.getValue(constants.KEY, constants.FACTORY);
if(StringUtils.isEmpty(key)) {
key = preferencesKey;
}
/* Save current KEY into session */
session.setAttribute(constants.KEY, key, PortletSession.APPLICATION_SCOPE);
model.addAttribute("entityList", getEntities());
model.addAttribute("preferencesKey", preferencesKey);
return "index";
}
}
It sounds like you are using a old version of spring-context.jar Spring Context API - Version 2.0.x.
Try using a later version Spring Context API - Version 3.0.x.