jboss-as-7.1.1、动态 Web 模块 3.0、JSF 2.0 (Mojarra)、Eclipse Indigo sr2
我有一个 EAR,Ynale.ear,它包含一个 YnaleImpl.jar 和一个 Ynale.war:
Ynale.ear
|-YnaleWeb.war
| |-META-INF
| | |-MANIFEST.MF:
| | Manifest-Version: 1.0
| | Class-Path: deployment.Ynale.ear.YnaleImpl
| |
| |-WEB-INF
| | |-beans.xml
| | | (empty)
| | |
| | |-faces-config.xml:
| | | <?xml version="1.0" encoding="UTF-8"?>
| | | <faces-config version="2.0"
| | | xmlns="http://java.sun.com/xml/ns/javaee"
| | | xmlns:xi="http://www.w3.org/2001/XInclude"
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| | | xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
| | | </faces-config>
| | |
| | |-web.xml:
| | <?xml version="1.0" encoding="UTF-8"?>
| | <web-app version="3.0"
| | xmlns="http://java.sun.com/xml/ns/javaee"
| | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| | xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
| | <display-name>YnaleWeb</display-name>
| | <context-param>
| | <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
| | <param-value>server</param-value>
| | </context-param>
| | <context-param>
| | <param-name>primefaces.THEME</param-name>
| | <param-value>redmond</param-value>
| | </context-param>
| | <servlet>
| | <servlet-name>Faces Servlet</servlet-name>
| | <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
| | <load-on-startup>1</load-on-startup>
| | </servlet>
| | <servlet-mapping>
| | <servlet-name>Faces Servlet</servlet-name>
| | <url-pattern>*.jsf</url-pattern>
| | </servlet-mapping>
| | <servlet-mapping>
| | <servlet-name>Faces Servlet</servlet-name>
| | <url-pattern>*.xhtml</url-pattern>
| | </servlet-mapping>
| | <session-config>
| | <session-timeout>300</session-timeout>
| | <cookie-config>
| | <name>JSESSIONID</name>
| | </cookie-config>
| | <tracking-mode>COOKIE</tracking-mode>
| | </session-config>
| | </web-app>
| |
| |-Login.xhtml
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
| <html xmlns="http://www.w3.org/1999/xhtml"
| xmlns:h="http://java.sun.com/jsf/html"
| xmlns:f="http://java.sun.com/jsf/core"
| xmlns:ui="http://java.sun.com/jsf/facelets">
| <h:head>
| <title>YNALE Log in page</title>
| </h:head>
| <f:view>
| <body>
| <div>#{textValue.value()}</div>
| </body>
| </f:view>
| </html>
|
|-lib
|-META_INF
| jboss-deployment-structure.xml:
| <jboss-deployment-structure>
| <ear-subdeployments-isolated>false</ear-subdeployments-isolated>
| <deployment>
| <dependecies>
| <module name="deployment.Ynale.ear.YnaleImpl" export="true"/>
| </dependencies>
| </deployment>
| <module name="deployment.Ynale.ear.YnaleImpl" >
| <resources>
| <resource-root path="lib/YnaleImpl.jar" />
| </resources>
| </module>
| </jboss-deployment-structure>
|
|-YnaleImpl.jar:
|-META-INF
| beans.xml:
| (empty)
| MANIFEST.MF:
| Manifest-Version: 1.0
|
|-org
|-ynale
|-utils
|-TextValue.class
package org.ynale.utils;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean
@RequestScoped
public class TextValue {
public TextValue() {}
public String value() {
return "TextValue";
}
}
Utility.jar 有一个 beans.xml,在启动时 WELD 系统会找到它并记录:
WELD-000106 Bean: Managed Bean [class org.ynale.utils.TextValue] with qualifiers [@Any @Default]
在 Web.war 我有 login.xhtml 有:
#{textValue.value()}
我在日志中没有错误(输出到 FIN/DEBUG),但从未调用 textValue.value()。我的页面上没有输出。
有任何想法吗?
编辑:在 WAR 内部定义的托管 Bean 工作正常。
编辑 2:对不起,我有一个,但忘了在帖子中包含:
<?xml version="1.0"?>
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"/>