【问题标题】:Unable to use JCA CICS resource with IBM WebSphere Application Server Liberty Profile无法将 JCA CICS 资源与 IBM WebSphere Application Server Liberty Profile 一起使用
【发布时间】:2017-02-14 10:32:31
【问题描述】:

我正在尝试为现有的 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.]

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

【问题讨论】:

    标签: websphere-liberty


    【解决方案1】:

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

    如果资源适配器只提供一个连接工厂(这通常是许多资源适配器的情况),那么配置将是:

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

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

    【讨论】:

    • 我之前尝试过这种语法,但没有成功。现在有了你的语法,我遇到了这个异常:java.lang.Exception: Lookup for java:comp/env/cicsjca failed. Exception: java.lang.ClassCastException: com.ibm.connector2.cics.ECIConnectionFactory incompatible with com.ibm.connector2.cics.ECIConnectionFactory
    • 该异常表明同一个类正在从 2 个不同的位置加载。您的 RAR 和一个 sharedLib jar 中是否有该类的副本?我怀疑您只需要在应用程序类加载器上指定 classProviderRef
    • 没错,cicseci.jar 和其他部门。也加载到共享库中。该应用程序使用一些使用相同 jar 的专有框架。我检查了这个...
    • 将 jar 从 sharedLib 移动到 EAR 解决了这个问题。 CICS 调用现在正在工作。感谢您的帮助。
    • @EmericChardiny,我正在尝试相同的步骤,甚至遵循的步骤与您的类似,但我得到了 javax.naming.NamingNotFoundException。一切似乎都是正确的。你能帮我吗?
    猜你喜欢
    • 2018-07-07
    • 2015-12-19
    • 2014-12-06
    • 1970-01-01
    • 1970-01-01
    • 2017-01-21
    • 1970-01-01
    • 2013-07-01
    • 1970-01-01
    相关资源
    最近更新 更多