Managedbean could not be create Can't set managed bean property

[nobr]I know that many people have had this issue in the past, well I have it now ,and I have tryed every solution I have found in the forums.

Some how I cannot get to create the managed bean.

I have used the myeclipse framework to create a simple example of JSF

I am using JDK 5

JBOSS 4

JSF Sun 1.1_01

here is the think I have two String properties that are inicialized by the user in a form, then in the next page I print another managed-bean.

When the app starts the container is supposed to create the bean from the faces-config. But I allways get:

13:28:37,657 ERROR [ApplicationImpl] Managedbean CentralBean could not be created Can't set managed bean property: 'cuantos'.

javax.faces.FacesException: Can't set managed bean property: 'cuantos'.

I have tryed to inicialize the property in the config file, but no matter what type I choose I allways get the same exception.

If I erase the property from the config file, then the form is displayed but at the next page I get a Unknown property'cuantos'

Here is my 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">

<faces-config >

<managed-bean>

<managed-bean-name>CentralBean</managed-bean-name>

<managed-bean-class>org.invias.bean.CentralBean</managed-bean-class>

<managed-bean-scope>session</managed-bean-scope>

<managed-property>

<property-name>user</property-name>

<property-class>java.lang.String</property-class>

<null-value></null-value>

</managed-property>

<managed-property>

<property-name>password</property-name>

<property-class>java.lang.String</property-class>

<value></value>

</managed-property>

<managed-property>

<property-name>cuantos</property-name>

<value>1</value>

</managed-property>

</managed-bean>

here is my java code:

publicfinalclass CentralBeanextends Objectimplements Serializable{

/**

*

*/

privatestaticfinallong serialVersionUID = 151531;

private Proceso procesos;

private Integer cuantos;

/**

*

*/

private String password =new String();

/**

*

*/

private String user =new String();

....

public String loginUser(){

System.out.println("loginuser");

//conecto con los beans.

//InitialContext ctx = new InitialContext();

//Object objref = ctx.lookup("ejb/Central");

//org.invias.ejb.CentralBean SessionBean = (org.invias.ejb.CentralBean) PortableRemoteObject.narrow(objref, CentralHome.class);

//SessionBean.setNombre(getUser());

//es = SessionBean.getText();

FacesContext facesContext = FacesContext.getCurrentInstance();

FacesMessage facesMessage =new FacesMessage("Nuevo Mensaje");

facesContext.addMessage("loginForm", facesMessage);

if("dani".equals(getUser()) &&"myeclipse".equals(getPassword())){

procesos =new Proceso();

cuantos =new Integer(1);

return"success";

}

return"failure";

}

.....

public Integer getCuantos(){

return cuantos;

}

publicvoid setCuantos(Integer cuan){

this.cuantos=cuan;

}

/**

* @param cuantos

*/

publicvoid setCuantos(int cuan){

System.out.println("setCuantos");

this.cuantos =new Integer(cuan);

}

/*

* (non-Javadoc)

* @see java.lang.Object#toString()

*/

public String toString(){

return"";

}

}

fairly simple....

This is the first page, that is supposed to recieve the user, get his user and password, and then proceed to display his info.

Here is my login.jsp:

<f:view>

<f:loadBundle basename="org.invias.MessageBundle" var="bundle" />

Login Page<br>

<h:form id="loginForm" rendered="true">

<h:outputLabel rendered="true" for="user" value="#{bundle.user_label}"/>

<h:inputText value="#{CentralBean.user}" rendered="true" required="true" id="user" />

<P><h:outputLabel rendered="true" for="password" value="#{bundle.password_label}" />

<h:inputSecret value="#{CentralBean.password}" rendered="true" required="false" redisplay="false" id="password" /><BR>

<h:commandButton value="#{bundle.login_button}" rendered="true" action="#{CentralBean.loginUser}" id="submit" />

</P></h:form></f:view>

Once I have user and password, I will look in a DB for the user info, for now I am trying to print some dummy data, but...

here is my code:

<%@ page language="java" pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<base href="<%=basePath%>">

<title>My JSF'Central.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">

<meta http-equiv="cache-control" content="no-cache">

<meta http-equiv="expires" content="0">

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

<meta http-equiv="description" content="This is my page">

<!--

<link rel="stylesheet" type="text/css" href="styles.css">

-->

</head>

<body>

<f:view>

<f:loadBundle basename="org.invias.MessageBundle" var="bundle" /> <br>

Bienvenido <h:outputLabel value="#{CentralBean.user}" rendered="true" for="user" />

<P>

</P><P>Usted tiene los siguinetes procesos: <h:outputText rendered="true" value="#{CentralBean.cuantos}" /></P>

<h:dataTable id="table" var="row" value="#{CentralBean.procesos}" binding="#{CentralBean.procesos}" border="1" rendered="true">

<h:column>

<h:outputText value="#{row.tipo}" />

</h:column>

</h:dataTable>

<h:form id="ProcesoForm" rendered="true">

id <h:inputText rendered="true" required="false" id="name" />

<h:commandButton value="Crear" rendered="true" id="submit" action="#{Central.ingresarProceso}" />

</h:form></f:view>

</body>

</html>

I have used the guide in a step by step manner, it worked well, but when I tryed to extend the example it failed. I have no idea why.

I all ready have a book about JSF, and according to the book my faces-config is ok, and my java code is working... So I am missing something, please help me find out, I have lost two days in this simple problem.

Thanks for the help

Daniel Castro

Any more info will be gandly given, and I will surely post the solution once I figure it out.[/nobr]

[11505 byte] By [EviDania] at [2007-10-3 8:53:08]
# 1

OK I have managed to make the faces work but I am getting another error.

Using another post, if you include the following:

<jsp:useBean id="CentralBean" class="org.invias.bean.CentralBean" type="org.invias.bean.CentralBean" scope="session" />

in the start of the jsp then everything runs somethly.

But now I am getting:

org.apache.jasper.JasperException: javax.servlet.jsp.JspException: Error getting property 'cuantos' from bean of type org.invias.bean.CentralBean

org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)

javax.servlet.http.HttpServlet.service(HttpServlet.java:810)

com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)

com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)

com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)

com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)

com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)

javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)

org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

I have no idea, I will keep trying to solve this.

Now after displaying the first face page and submiting the form I get:

org.apache.jasper.JasperException: javax.servlet.jsp.JspException: Error getting property 'procesos' from bean of type org.invias.bean.CentralBean

org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)

javax.servlet.http.HttpServlet.service(HttpServlet.java:810)

com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)

com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)

com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)

com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)

com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)

javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)

org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

root cause

javax.servlet.ServletException: javax.servlet.jsp.JspException: Error getting property 'procesos' from bean of type org.invias.bean.CentralBean

org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:854)

org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)

org.apache.jsp.Central_jsp._jspService(Central_jsp.java:136)

I changed some stuff:

my faces-config.xml

<faces-config >

<managed-bean>

<managed-bean-name>CentralBean</managed-bean-name>

<managed-bean-class>org.invias.bean.CentralBean</managed-bean-class>

<managed-bean-scope>session</managed-bean-scope>

<managed-property>

<property-name>user</property-name>

<property-class>java.lang.String</property-class>

<null-value></null-value>

</managed-property>

<managed-property>

<property-name>password</property-name>

<property-class>java.lang.String</property-class>

<null-value></null-value>

</managed-property>

<managed-property>

<property-name>cuantos</property-name>

<property-class>java.lang.String</property-class>

<null-value></null-value>

</managed-property>

<managed-property>

<property-name>procesos</property-name>

<property-class>java.util.HashMap</property-class>

<map-entries>

<key-class>java.lang.String</key-class>

<value-class>java.lang.Integer</value-class>

<map-entry>

<key>Arauca</key>

<value>1</value>

</map-entry>

</map-entries>

</managed-property>

</managed-bean>

and some code in my jsp page:

<h:outputLabel

rendered="true" value="#{Central.cuantos}" /></P>

<h:dataTable id="table" var="row" value="#{CentralBean.procesos}" border="1" rendered="true">

Right now I am loosing my patience and time, so, if I dont overcome this I will drop JSF and switch to regular jsp.

Message was edited by:

Evil.dani

Evil.dania at 2007-7-15 4:02:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...