[jboss-user] [Tomcat, HTTPD, Servlets & JSP] - Problems with myfaces - ClassCastException JbossActionReques

commy do-not-reply at jboss.com
Wed Sep 6 20:07:52 EDT 2006


Hi there!

i've got a problem with my myfaces portlet.

With the following set of files, i can add resources, but when i click on Edit, i get the following Exception:

Here's the bean, called Resource.java


  | /*
  |  * Resource.java
  |  *
  |  * Created on September 4, 2006, 9:58 PM
  |  *
  |  * To change this template, choose Tools | Template Manager
  |  * and open the template in the editor.
  |  */
  | 
  | package iro.model;
  | 
  | import java.io.Serializable;
  | import javax.persistence.Entity;
  | import javax.persistence.GeneratedValue;
  | import javax.persistence.GenerationType;
  | import javax.persistence.Id;
  | import javax.persistence.Basic;
  | 
  | /**
  |  *
  |  * @author root
  |  */
  | @Entity
  | public class Resource implements Serializable {
  | 
  |     @Id
  |     @GeneratedValue(strategy = GenerationType.AUTO)
  |     private Long id;
  |     @Basic
  |     private String name;
  |     @Basic
  |     private String description;
  |     
  |     /** Creates a new instance of Resource */
  |     public Resource() {
  |     }
  | 
  |     public String getName(){
  |         return this.name;
  |     }
  |     
  |     public void setName(String newName){
  |         this.name = newName;
  |     }
  |     
  |     public String getDescription(){
  |         return this.description;
  |     }
  |     
  |     public void setDescription(String newDescription){
  |         this.description = newDescription;
  |     }
  |     
  |     public Long getId() {
  |         return id;
  |     }
  | 
  |     public void setId(Long id) {
  |         this.id = id;
  |     }
  | 
  |     public String toString() {
  |         //TODO change toString() implementation to return a better display name
  |         return "" + this.id;
  |     }
  |     
  | }
  | 
  | 

here are the jsf files...

Detail.jsf

  | <%@page contentType="text/html"%>
  | <%@page pageEncoding="UTF-8"%>
  | <%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
  | <%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
  | <head>
  |     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  |     <title>Detail of Resource</title>
  | </head>
  | <f:view>
  |     <h:messages style="color: green" layout="table"/>
  |     <h1>Detail of resource</h1>
  |     <h:form>
  |         <h:panelGrid columns="2">
  |             <h:outputText>Name:</h:outputText>
  |             <h:outputText value="#{resource.resource.name}" title="Name" />
  |             <h:outputText>Description:</h:outputText>
  |             <h:outputText value="#{resource.resource.description}" title="Description" />
  |             <h:outputText>Id:</h:outputText>
  |             <h:outputText value="#{resource.resource.id}" title="Id" />
  |         </h:panelGrid>
  |         <h:commandLink action="#{resource.editSetup}">
  |             <f:param name="id" value="#{resource.resource.id}"/>
  |             <h:outputText value="Edit"/>
  |         </h:commandLink>
  |         <br>
  |         <h:commandLink action="resource_list" value="Show All Resource"/>
  |         <br>
  |         <a href="/WebApplication11/index.jsp">Back to index</a>
  |     </h:form>
  | </f:view>
  | 

Edit.jsf

  | <%@page contentType="text/html"%>
  | <%@page pageEncoding="UTF-8"%>
  | <%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
  | <%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
  | <head>
  |     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  |     <title>Edit Resource</title>
  | </head>
  | <f:view>
  |     <h:messages style="color: green" layout="table"/>
  |     <h1>Edit resource</h1>
  |     <h:form>
  |         <h:panelGrid columns="2">
  |             <f:verbatim>Name</f:verbatim>
  |             <h:inputText id="name" value="#{resource.resource.name}" title="Name" />
  |             <f:verbatim>Description</f:verbatim>
  |             <h:inputText id="description" value="#{resource.resource.description}" title="Description" />
  |         </h:panelGrid>
  |         <h:commandLink action="#{resource.edit}" value="Save"/>
  |         <br>
  |         <h:commandLink action="resource_list" value="Show All Resource"/>
  |         <br>
  |         <a href="/WebApplication11/index.jsp">Back to index</a>
  |     </h:form>
  | </f:view>
  | 
  | 

List.jsf

  | <%@page contentType="text/html"%>
  | <%@page pageEncoding="UTF-8"%>
  | <%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
  | <%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
  | <head>
  |     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  |     <title>List Resource</title>
  | </head>
  | <f:view>
  |     <h:messages style="color: green" layout="table"/>
  |     <h1>Listing Resources</h1>
  |     <h:form>
  |         <h:dataTable value='#{resource.resources}' var='item' border="1" cellpadding="2" cellspacing="0">
  |             <h:column>
  |                 <f:facet name="header">
  |                     <h:outputText value="Name"/>
  |                 </f:facet>
  |                 <h:outputText value="#{item.name}"/>
  |             </h:column>
  |             <h:column>
  |                 <f:facet name="header">
  |                     <h:outputText value="Description"/>
  |                 </f:facet>
  |                 <h:outputText value="#{item.description}"/>
  |             </h:column>
  |             <h:column>
  |                 <f:facet name="header">
  |                     <h:outputText value="Id"/>
  |                 </f:facet>
  |                 <h:commandLink action="#{resource.detailSetup}">
  |                     <f:param name="id" value="#{item.id}"/>
  |                     <h:outputText value="#{item.id}"/>
  |                 </h:commandLink>
  |             </h:column>
  |             <h:column>
  |                 <h:commandLink action="#{resource.destroy}">
  |                     <f:param name="id" value="#{item.id}"/>
  |                     <h:outputText value='Destroy'/>
  |                 </h:commandLink>
  |                 <h:outputText value=" "/>
  |                 <h:commandLink action="#{resource.editSetup}" value="Edit">
  |                     <f:param name="id" value="#{item.id}"/>
  |                 </h:commandLink>
  |             </h:column>
  |         </h:dataTable>
  |         <h:commandLink action="#{resource.createSetup}">
  |             <h:outputText value="New Resource"/>
  |         </h:commandLink>
  |         <br>
  |         <a href="/WebApplication11/index.jsp">Back to index</a>
  |     </h:form>
  | </f:view>
  | 

New.jsf

  | <%@page contentType="text/html"%>
  | <%@page pageEncoding="UTF-8"%>
  | <%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
  | <%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
  | <head>
  |     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  |     <title>New Resource</title>
  | </head>
  | <f:view>
  |     <h:messages style="color: green" layout="table"/>
  |     <h1>New resource</h1>
  |     <h:form>
  |         <h:panelGrid columns="2">
  |             <f:verbatim>Name</f:verbatim>
  |             <h:inputText id="name" value="#{resource.resource.name}" title="Name" />
  |             <f:verbatim>Description</f:verbatim>
  |             <h:inputText id="description" value="#{resource.resource.description}" title="Description" />
  |         </h:panelGrid>
  |         <h:commandLink action="#{resource.create}" value="Create"/>
  |         <br>
  |         <h:commandLink action="resource_list" value="Show All Resource"/>
  |         <br>
  |         <a href="/WebApplication11/index.jsp">Back to index</a>
  |     </h:form>
  | </f:view>
  | 
  | 

Here's the faces-config.xml


  | <?xml version="1.0" encoding="UTF-8"?>
  | <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
  | <!-- =========== FULL CONFIGURATION FILE ================================== -->
  | <faces-config xmlns="http://java.sun.com/JSF/Configuration">
  |   <converter>
  |     <converter-for-class>iro.model.Resource</converter-for-class>
  |     <converter-class>iro/controller.ResourceConverter</converter-class>
  |   </converter>
  |   <managed-bean>
  |     <managed-bean-name>resource</managed-bean-name>
  |     <managed-bean-class>iro.controller.ResourceController</managed-bean-class>
  |     <managed-bean-scope>session</managed-bean-scope>
  |   </managed-bean>
  |   <navigation-rule>
  |   <from-view-id>/iro.view/resource/*</from-view-id>
  |     <navigation-case>
  |       <from-outcome>resource_create</from-outcome>
  |       <to-view-id>/iro.view/resource/New.jsp</to-view-id>
  |     </navigation-case>
  |     <navigation-case>
  |       <from-outcome>resource_list</from-outcome>
  |       <to-view-id>/iro.view/resource/List.jsp</to-view-id>
  |     </navigation-case>
  |     <navigation-case>
  |       <from-outcome>resource_edit</from-outcome>
  |       <to-view-id>/iro.view/resource/Edit.jsp</to-view-id>
  |     </navigation-case>
  |     <navigation-case>
  |       <from-outcome>resource_detail</from-outcome>
  |       <to-view-id>/iro.view/resource/Detail.jsp</to-view-id>
  |     </navigation-case>
  |   </navigation-rule>
  |   <lifecycle/>
  |     <application>
  |       <locale-config/>
  |     </application>
  |    <factory/>
  | </faces-config>
  | 
  | 

the portlet.xml

  | <?xml version="1.0" encoding="UTF-8"?>
  | <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
  |              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  |              xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd /opt/SUNWps/dtd/portlet.xsd"
  |              version="1.0">
  | <!--  RESOURCE PORTLET -->
  |    <portlet>
  |       <portlet-name>IroResourcePortlet</portlet-name>
  |       <portlet-class>org.apache.myfaces.portlet.MyFacesGenericPortlet</portlet-class>
  |       <init-param>
  |          <name>default-view</name>
  |          <value>/iro.view/resource/List.jsp</value>
  |       </init-param>
  |       <supports>
  |          <mime-type>text/html</mime-type>
  |          <portlet-mode>VIEW</portlet-mode>
  |       </supports>
  |       <portlet-info>
  |          <title>IroResourcePortlet</title>
  |       </portlet-info>
  |    </portlet>
  | </portlet-app>
  | 

and here's the web.xml

  | <?xml version="1.0" encoding="UTF-8"?>
  | <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  |     <listener>
  | 		<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
  | 	</listener>
  | </web-app>
  | 

i already tried to add a jsf mapping to the web.xml, but it didn't work.

Caused by: java.lang.ClassCastException: org.jboss.portlet.JbossActionRequest cannot be cast to javax.servlet.http.HttpServletRequest

can anyone help me?

greetings markus

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969919#3969919

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969919



More information about the jboss-user mailing list