1

我在一个.xhtml文件中有这个代码:

<h:inputText id="userName" value="#{userEntity.userName}"
             title="${bundle['signup.createuser.username']}"
             maxlength="#{jsfConst.userNameMaxFieldSize}">
</h:inputText>

但是在 Embedded Glassfish 4.0 中maxlength部署文件时永远不会设置该属性。war我将相同的war文件部署到 Glassfish 4.0 安装中,它工作正常。

我在我的 POM 中使用了这个 Glassfish 依赖项:

<dependency>
    <groupId>org.glassfish.main.extras</groupId>
    <artifactId>glassfish-embedded-all</artifactId>
    <version>4.0</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.jboss.arquillian.container</groupId>
    <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
    <version>1.0.0.CR3</version>
    <scope>test</scope>
</dependency>

这是jsfConst.java文件:

@ManagedBean
@Singleton
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
public class JsfConst {
    public int getEmailFieldSize() {
        return Const.emailFieldSize;
    }

    public int getUserNameMaxFieldSize() {
        return Const.userNameMaxFieldSize;
    }
}

我的问题是,Embedded Glassfish 缺少什么使其无法启用 EL?

更新:

这是web.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<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>
    <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>*.xhtml</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
    </welcome-file-list>
    <error-page>
        <exception-type>com.sun.faces.context.FacesFileNotFoundException</exception-type>
        <location>/pagenotfound.jsp</location>
    </error-page>
    <error-page>
        <exception-type>javax.faces.application.ViewExpiredException</exception-type>
        <location>/sessionexpired.jsp</location>
    </error-page>
    <listener>
        <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
    </listener>
</web-app>
4

1 回答 1

0

在 Arquillian 中,您需要声明构成 WAR 文件的所有类以进行部署和测试。只需JsfConst使用在 WAR 中注册ShrinkWrap.create(WebArchive.class, "createUser.war").addClass(JsfConst.class)

于 2014-04-01T17:52:00.493 回答