gpt4 book ai didi

java - [java.lang.ClassCastException : CustomPortlet incompatible with javax. portlet.Portlet

转载 作者:搜寻专家 更新时间:2023-11-01 03:24:06 24 4
gpt4 key购买 nike

我尝试在 MyEclipse tutorial 之后使用 MyEclipse 创建 portlet .我完成了所有步骤并将项目导出为 WAR。当把它安装到 Portal 并放在页面上时,它说“这个 portlet 不可用”。

查找相关讨论here .

异常是:SRVE0068E:应用程序 [PA_Vijay] 中的 servlet [CustomPortlet] 的服务方法之一抛出异常。创建的异常:[java.lang.ClassCastException:CustomPortlet 与 javax.portlet.Portlet 不兼容

这是我的java代码:

import java.io.IOException;
import java.io.PrintWriter;

import javax.portlet.GenericPortlet;
import javax.portlet.PortletConfig;
import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.UnavailableException;


public class CustomPortlet extends GenericPortlet {

/**
* Helper method to serve up the view mode.
*/

public void init(PortletConfig pc)throws UnavailableException, PortletException{

super.init(pc);
}

protected void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
response.setContentType("text/html");
PrintWriter writer = response.getWriter();
writer.print("<p>This is the custom portlet created from MyEclipseIDE</p>");
}

}

问题出在哪里?

最佳答案

检查您是否没有将 portlet-api.jar 与您的应用程序一起部署。如果您将它与您的应用程序一起部署,它可能会导致问题。

关于java - [java.lang.ClassCastException : CustomPortlet incompatible with javax. portlet.Portlet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20015153/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com