使用 JSF Flows 将 WAR 文件转换为 EAR 文件。WAR文件结构为:
booking/booking-flow.xml
booking/booking.xhtml
booking/confirm.xhtml
booking/print.xhtml
booking/showtimes.xhtml
WEB-INF/classes/org/javaee7/movieplex7/booking/Booking.class
WEB-INF/faces-config.xml
WEB-INF/template.xhtml
WEB-INF/web.xml
faces-config.xml
是:
<faces-config version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
</faces-config>
web.xml
是:
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>javax.faces.CLIENT_WINDOW_MODE</param-name>
<param-value>url</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>/faces/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
booking-flow.xml
是:
<faces-config version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
<flow-definition id="booking">
<flow-return id="goHome">
<from-outcome>/index</from-outcome>
</flow-return>
</flow-definition>
</faces-config>
JSF Flow 在打包为 WAR 文件时可以正常工作。但它给出了以下错误:
org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.faces.flow.FlowScoped
当它被打包为 EAR 文件中的 WAR 文件时。EAR结构是:
booking-1.0-SNAPSHOT.war
./lib
./lib/contracts-1.0-SNAPSHOT.jar
booking-1.0-SNAPSHOT.war
结构是:
booking/booking-flow.xml
booking/booking.xhtml
booking/confirm.xhtml
booking/print.xhtml
booking/showtimes.xhtml
WEB-INF/beans.xml
WEB-INF/classes/org/javaee7/movieplex7/booking/Booking.class
WEB-INF/classes/org/javaee7/movieplex7/booking/MainPage.class
WEB-INF/faces-config.xml
WEB-INF/web.xml
MainPage
需要类才能从 REST 端点检索结果。资源库合约存储在 lib 目录中。
在 GlassFish 4.1 上部署应用程序。
知道为什么这在独立的 WAR 文件中有效,但在打包在 EAR 文件中时无效?