我正在尝试在jboss-portal-2.7.2上部署我的应用程序,它给了我以下错误:
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
有谁知道如何解决这个问题?
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";
}
}
答案 0 :(得分:2)
Caused by: java.lang.NoSuchMethodError: org.springframework.web.portlet.context.ConfigurablePortletApplicationContext.setId(Ljava/lang/String;)V
听起来你正在使用旧版本的spring-context.jar Spring Context API - Version 2.0.x。
尝试使用更高版本Spring Context API - Version 3.0.x。