【问题标题】:How to reference a websphere Resource Environment Provider in web.xml?如何在 web.xml 中引用 websphere 资源环境提供者?
【发布时间】:2014-11-08 11:38:50
【问题描述】:

我们使用资源环境提供程序在 websphere 中定义了自定义属性,该提供程序使用以下说明设置

http://www.ibm.com/developerworks/websphere/library/techarticles/0611_totapally/0611_totapally.html

在第 6 节的那篇文章中,它说"For a Web module, open the web.xml file (for an EJB module, open the ejb-jar.xml file ) using the deployment descriptor editor."

我需要手动编辑web.xml,因为此时我无法使用 IBM 开发工具。是否有文档可以提供 GUI 创建的 xml 片段?在这一点上,谷歌让我失望了

【问题讨论】:

    标签: java xml websphere web.xml


    【解决方案1】:

    您可以手动将其添加到web.xml和ibm-web-bnd.xml中(此示例对应您提到的DW文章,请相应更改):

    web.xml

    <resource-env-ref>
        <description />
        <resource-env-ref-name>MyConstants</resource-env-ref-name>
        <resource-env-ref-type>com.ibm.acme.ree.lib.Config</resource-env-ref-type>
    </resource-env-ref>
    

    ibm-web-bnd.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <web-bnd xmlns="http://websphere.ibm.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd"  version="1.0">
        <resource-env-ref name="MyConstants" binding-name="rep/dev/app1/MyResourceReference" />
    </web-bnd>
    

    之后你可以使用JNDI查找java:comp/env/MyConstants并获取Config对象。

    【讨论】:

      猜你喜欢
      • 2015-10-20
      • 1970-01-01
      • 2010-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-10
      相关资源
      最近更新 更多