【问题标题】:Set Project Stage with JNDI on Glassfish 4.1在 Glassfish 4.1 上使用 JNDI 设置项目阶段
【发布时间】:2018-01-19 10:47:55
【问题描述】:

我正在寻找使用 JNDI 配置在 Glassfish (v4.1.1 build 1) 上设置项目阶段,以允许我的服务器拥有每个不同的项目阶段,并允许我在不更改 javax.faces.PROJECT_STAGE 的情况下使用 Git 推送修改每次推送时在 web.xml 中。

我已经在this post 中尝试过,但它似乎不起作用,可能是因为它不是同一个 Glassfish 版本。

在 web.xml 中(在我的项目中)

<resource-ref>
    <res-ref-name>jsf/ProjectStage</res-ref-name>
    <res-type>java.lang.String</res-type>
    <mapped-name>javax.faces.PROJECT_STAGE</mapped-name>
</resource-ref>

在 domain.xml(我的服务器使用的域)中

<custom-resource factory-class="com.sun.faces.application.ProjectStageJndiFactory" res-type="java.lang.String" jndi-name="javax.faces.PROJECT_STAGE">
    <property name="stage" value="Development"></property>
</custom-resource>

我也尝试使用&lt;property name="value" value="Development"&gt;&lt;/property&gt; 而不是name="stage"

但是,当我显示#{facesContext.application.projectStage} 时,它显示为Production,因为它看起来是默认阶段。

希望你能帮助我,谢谢!

【问题讨论】:

    标签: jsf glassfish jndi


    【解决方案1】:

    解决了我的问题!

    似乎在手动编辑 domain.xml 文件时创建 JNDI 资源并不能像我解释的那样正确创建资源 here

    所以它与使用 asadmin 命令创建的 JNDI 自定义资源一起正常工作。

    JNDI 自定义资源创建命令

    create-custom-resource --restype java.lang.String --factoryclass com.sun.faces.application.ProjectStageJndiFactory --property "stage=Development" javax.faces.PROJECT_STAGE
    

    web.xml

    <resource-ref>
        <res-ref-name>jsf/ProjectStage</res-ref-name>
        <res-type>java.lang.String</res-type>
        <mapped-name>javax.faces.PROJECT_STAGE</mapped-name>
    </resource-ref>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-25
      • 2012-10-31
      • 2023-03-22
      • 2012-02-01
      相关资源
      最近更新 更多