掲示板
Error Cast javax.portlet.Portlet
12年前 に Roberto Rodriguez によって更新されました。
Error Cast javax.portlet.Portlet
New Member 投稿: 17 参加年月日: 10/08/18 最新の投稿
Hi get this error:
com.sample.jsp.portlet.JSPPortlet cannot be cast to javax.portlet.Portlet
JSPPortlet.java
liferay-portlet.xml
com.sample.jsp.portlet.JSPPortlet cannot be cast to javax.portlet.Portlet
JSPPortlet.java
package com.sample.jsp.portlet;
import java.io.IOException;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
public class JSPPortlet extends GenericPortlet {
public void serveResource(ResourceRequest req, ResourceResponse res)
throws PortletException, IOException {
boolean logo = true;
if (logo) {
System.out.println("hello");
}
}
public void doView(
RenderRequest renderRequest, RenderResponse renderResponse)
throws IOException, PortletException {
PortletRequestDispatcher portletRequestDispatcher =
getPortletContext().getRequestDispatcher("/view.jsp");
portletRequestDispatcher.include(renderRequest, renderResponse);
}
}
liferay-portlet.xml
<!--?xml version="1.0"?-->
<liferay-portlet-app>
<portlet>
<portlet-name>ServeResourcePortlet</portlet-name>
<icon>/icon.png</icon>
<instanceable>true</instanceable>
<header-portlet-css>/css/test.css</header-portlet-css>
<footer-portlet-javascript>/js/test.js</footer-portlet-javascript>
</portlet>
<role-mapper>
<role-name>administrator</role-name>
<role-link>Administrator</role-link>
</role-mapper>
<role-mapper>
<role-name>guest</role-name>
<role-link>Guest</role-link>
</role-mapper>
<role-mapper>
<role-name>power-user</role-name>
<role-link>Power User</role-link>
</role-mapper>
<role-mapper>
<role-name>user</role-name>
<role-link>User</role-link>
</role-mapper>
</liferay-portlet-app>
12年前 に Mani kandan によって更新されました。
RE: Error Cast javax.portlet.Portlet
Expert 投稿: 492 参加年月日: 10/09/15 最新の投稿
Hi Roberto,
This kind of exception usually happens when some classes are twice on the classpath - e.g. javax.portlet.Portlet in this case. You're inheriting from one but the typecast tries to cast to the other. The message is puzzling, but once you grasp that there are two distinct instances with the same name, it makes a lot more sense.
I guess you deployed too many jars with your own portlet - especially "portlet.jar" should be on the server's classpath, not on the webapp's/portlet's. That's why the default bundle has it in TOMCAT_HOME/lib/ext. It must not go to TOMCAT_HOME/webapps/YOUR_WEBAPP/WEB-INF/lib
This kind of exception usually happens when some classes are twice on the classpath - e.g. javax.portlet.Portlet in this case. You're inheriting from one but the typecast tries to cast to the other. The message is puzzling, but once you grasp that there are two distinct instances with the same name, it makes a lot more sense.
I guess you deployed too many jars with your own portlet - especially "portlet.jar" should be on the server's classpath, not on the webapp's/portlet's. That's why the default bundle has it in TOMCAT_HOME/lib/ext. It must not go to TOMCAT_HOME/webapps/YOUR_WEBAPP/WEB-INF/lib
9年前 に Jeet Chatterjee によって更新されました。
RE: Error Cast javax.portlet.Portlet
Junior Member 投稿: 33 参加年月日: 14/11/22 最新の投稿
Thanks it worked for me