How to reference a websphere Resource Environment Provider in web.xml?

早过忘川 提交于 2019-12-23 02:27:18

问题


We have custom properties defined in websphere using a Resource Environment provider that was setup using the instructions on

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

In that article in section 6, it says "For a Web module, open the web.xml file (for an EJB module, open the ejb-jar.xml file ) using the deployment descriptor editor."

I need to edit the web.xml by hand since the IBM development tools are unavailable to me at this time. Is there documentation somewhere that would provide the xml fragments that the GUI creates? Google has failed me on this point


回答1:


You can add it manually into web.xml and ibm-web-bnd.xml (this is example that corresponds to the DW article you mentioned, please change it accordingly):

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>

After that you can use JNDI to lookup java:comp/env/MyConstants and get Config object.



来源:https://stackoverflow.com/questions/25839671/how-to-reference-a-websphere-resource-environment-provider-in-web-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!