无法将 JCA CICS 资源与 IBM WebSphere Application Server Liberty Profile 一起使用

Unable to use JCA CICS resource with IBM WebSphere Application Server Liberty Profile

我正在尝试为现有的 EAR 应用程序设置 WLP。 此设置适用于传统的 WAS 9。

问题出在 JCA CICS 资源适配器调用上。

server.xml :

<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">

    <!-- Enable features -->
    <featureManager>
        <feature>javaee-7.0</feature>
    </featureManager>

    <!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
    <httpEndpoint id="defaultHttpEndpoint"
                  host="*"
                  httpPort="9080"
                  httpsPort="9443" />

    <!-- Automatically expand WAR files and EAR files -->
    <applicationManager autoExpand="true"/>

    <library id="sharedLibs">
        <fileset dir="/work/sharedlibs" includes="*.jar"/>
        <folder dir="/work" />
    </library>

    <resourceAdapter
            autoStart="true"
            id="eciResourceAdapter"
            location="/work/cicseci.rar">
    </resourceAdapter>

    <connectionFactory id="CTGDV06" jndiName="jca/CTGDV06" >
        <properties.eciResourceAdapter.javax.resource.cci.ConnectionFactory
                connectionUrl="tcp://*******"
                serverName="*******"
                userName="*******"
                portNumber="2006"
         />
    </connectionFactory>

    <application type="ear" id="app" location="app.ear" name="app">
        <classloader
                commonLibraryRef="sharedLibs"
                classProviderRef="eciResourceAdapter" />
    </application>
</server>

在 ibm-web-bnd.xml 中:

<resource-ref name="cicsjca" binding-name="jca/CTGDV06"></resource-ref>

在 web.xml 中:

<resource-ref id="ResourceRef_Cics_Jca">
    <description>Acces CICS</description>
    <res-ref-name>cicsjca</res-ref-name>
    <res-type>javax.resource.cci.ConnectionFactory</res-type>
    <res-auth>Application</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

启动正常,但访问 JCA 失败:

java.lang.Exception: Lookup for java:comp/env/cicsjca failed. Exception: javax.naming.NamingException: CWNEN1001E: The object referenced by the java:comp/env/cicsjca JNDI name could not be instantiated. If the reference name maps to a JNDI name in the deployment descriptor bindings for the application performing the JNDI lookup, make sure that the JNDI name mapping in the deployment descriptor binding is correct. If the JNDI name mapping is correct, make sure the target resource can be resolved with the specified name relative to the default initial context. 
[Root exception is com.ibm.wsspi.injectionengine.InjectionException: CWNEN0030E: The server was unable to obtain an object instance for the java:comp/env/cicsjca reference.  The exception message was: CWNEN1003E: The server was unable to find the jca/CTGDV06 binding with the javax.resource.cci.ConnectionFactory type for the java:comp/env/cicsjca reference.]

我不明白这个设置有什么问题,任何帮助都将不胜感激!

正确的配置取决于资源适配器提供了多少连接工厂实现。

如果资源适配器只提供一个连接工厂(许多资源适配器通常都是这种情况),则配置为:

<connectionFactory id="CTGDV06" jndiName="jca/CTGDV06" >
    <properties.eciResourceAdapter
            connectionUrl="tcp://*******"
            serverName="*******"
            userName="*******"
            portNumber="2006"
     />
</connectionFactory>

有关如何在 Liberty 中为 JCA 资源适配器指定配置的完整详细信息,请参阅知识中心here