jboss-as-7.1.1,动态网络模块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"/>
答案 0 :(得分:2)
Weld是一个CDI实现,它不扫描JSF 2特定的注释,它只扫描CDI特定的注释,如@Named
。你有一个JSF 2特定的@ManagedBean
注释。为此,您需要在JAR中具有JSF 2兼容/META-INF/faces-config.xml
,以便使JF文件中的JSF 2 Web应用程序扫描具有JSF 2特定注释的类,该文件位于/WEB-INF/lib
中。