Anyone knows why my xhtml page does not work with its named bean?
I get Welcome #{indexBean.userName}
in the browser. IndexBean is @Named, @SessionScoped and implements Serializable.
index.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<h:outputStylesheet library="css" name="default.css"/>
<title>Admin Panel</title>
</h:head>
<h:body>
<h:form>
<h2>Welcome #{indexBean.userName}</h2>
</h:form>
</h:body>
</html>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID"
version="3.0">
<display-name>WebAdmin</display-name>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>FacesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/WEB-INF/faces/index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
Bean
import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
@Named
@SessionScoped
public class IndexBean implements Serializable {
private static final long serialVersionUID = 1L;
MyFaces
INFO: Reading config : jar:file:/C:/tomee16/lib/openwebbeans-el22-1.2.1.jar!/META-INF/faces-config.xml
Dec 15, 2013 10:27:54 PM org.apache.myfaces.config.DefaultFacesConfigurationProvider getClassloaderFacesConfig INFO: Reading config : jar:file:/C:/tomee16/lib/openwebbeans-jsf-1.2.1.jar!/META-INF/faces-config.xml Dec 15, 2013 10:27:54 PM org.apache.myfaces.config.LogMetaInfUtils logArtifact INFO: Artifact 'myfaces-api' was found in version '2.1.13' from path 'file:/C:/tomee16/lib/myfaces-api-2.1.13.jar' Dec 15, 2013 10:27:54 PM org.apache.myfaces.config.LogMetaInfUtils logArtifact INFO: Artifact 'myfaces-impl' was found in version '2.1.13' from path 'file:/C:/tomee16/lib/myfaces-impl-2.1.13.jar'
@Named("indexBean") @ManagedBean @SesionScoped
– Paul Samsotha