Showing posts with label JSF. Show all posts
Showing posts with label JSF. Show all posts

February 9, 2011

javax.faces.FacesException: Cant set managed bean property:



Topic: JSF 1.2

Application Server: JBoss 4.2.2GA

Exception:

javax.faces.FacesException: Cant set managed bean property: personname.
at com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:556)
at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:82)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:45)
at org.apache.el.parser.AstValue.getValue(AstValue.java:86)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:101)
at javax.faces.component.UIOutput.getValue(UIOutput.java:173)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:189)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:320)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:200)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:836)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:896)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)


java.lang.NoSuchMethodException: Unknown property 'personname'
at com.sun.org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1777)
at com.sun.faces.config.ManagedBeanFactoryImpl.setPropertiesIntoBean(ManagedBeanFactoryImpl.java:647)
at com.sun.faces.config.ManagedBeanFactoryImpl.newInstance(ManagedBeanFactoryImpl.java:317)
at com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:546)
at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:82)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)


Resolution:

The managed property name set in the faces-config.xml file within the <managed-property> and the <property-name> elements does not match with the JavaBean property name as in the Managed Bean class and/or with the property name in the JSF tags in the JSPs. The property name in the managed bean class, as per JavaBean conventions, must be the same as set in the faces-config.xml configuration file as well as the property name used in the JSF tags in any of the JSPs.

Exception sending context initialized event to listener instance of class org.jboss.web.jsf.integration.config.JBossJSFConfigureListener javax.faces.FacesException: Can't parse configuration file: jndi:/localhost/AppName/WEB-INF/faces-config.xml


Topic: JSF 1.2

Application Server: JBoss 4.2.2GA

Exception:

Exception sending context initialized event to listener instance of class org.jboss.web.jsf.integration.config.JBossJSFConfigureListener
javax.faces.FacesException: Can't parse configuration file: jndi:/localhost/JSFWebapp/WEB-INF/faces-config.xml: Error at line 17 column 5: The element type "managed-bean-scope" must be terminated by the matching end-tag "</managed-bean-scope>".
at com.sun.faces.config.ConfigureListener.parse(ConfigureListener.java:1438)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:376)
at org.jboss.web.jsf.integration.config.JBossJSFConfigureListener.contextInitialized(JBossJSFConfigureListener.java:69)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3856)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:790)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:770)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)


Resolution:

The exception occurs due to an error in the JSF-specific configuration file, faces-config.xml, which must comply with XML rules for well-formed-ness and validity. Check for an incorrectly terminated XML element or an incorrectly spelled element, or other such errors in the faces-config.xml

The error message in the Server console log also pin-points the line number where the error has occured, fairly well.

Exception sending context initialized event to listener instance of class org.jboss.web.jsf.integration.config.JBossJSFConfigureListener javax.faces.FacesException: java.lang.ClassCastException: com.sun.faces.lifecycle.LifecycleFactoryImpl

Topic: JSF 1.2

Application Server: JBoss 4.2.2GA

Exception:


ERROR [[/JSFWebapp]] Exception sending context initialized event to listener instance of class org.jboss.web.jsf.integration.config.JBossJSFConfigureListener
javax.faces.FacesException: java.lang.ClassCastException: com.sun.faces.lifecycle.LifecycleFactoryImpl
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:387)
at org.jboss.web.jsf.integration.config.JBossJSFConfigureListener.contextInitialized(JBossJSFConfigureListener.java:69)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3856)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:790)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:770)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.apache.catalina.core.StandardContext.init(StandardContext.java:5312)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)



Resolution:


Removing 2 jars: jsf-api.jar and jsf-impl.jar removed the exception for me. However, some other jars that may have to be removed: el-api.jar, el-ri.jar, jsf-tlds.jar

The exception is caused, apparently, due to a versioning issue between the jars in the lib of the Web Application and the jars in the JBoss Application Server.

February 8, 2011

Java Server Faces (JSF) - Hello World Example Code

Jars to be added to the lib folder of the Web Application


commons-beanutils.jar
commons-collections.jar
commons-digester.jar
commons-logging.jar
jstl.jar
standard.jar
jsf-api.jar
jsf-impl.jar