Foros de discusión
Error Cast javax.portlet.Portlet
Roberto Rodriguez, modificado hace 12 años.
Error Cast javax.portlet.Portlet
New Member Mensajes: 17 Fecha de incorporación: 18/08/10 Mensajes recientes
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>
Mani kandan, modificado hace 12 años.
RE: Error Cast javax.portlet.Portlet
Expert Mensajes: 492 Fecha de incorporación: 15/09/10 Mensajes recientes
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
Jeet Chatterjee, modificado hace 9 años.
RE: Error Cast javax.portlet.Portlet
Junior Member Mensajes: 33 Fecha de incorporación: 22/11/14 Mensajes recientes
Thanks it worked for me