当前位置: 首页 > 知识库问答 >
问题:

自由

季森
2023-03-14

我正在尝试使用 JCA 和 CICSECI 功能通过 CICS 事务网关连接到 IBM 大型机。

我的Servlet代码是:

package com.ebs.jca.web;

import java.io.IOException;

import javax.annotation.Resource;
import javax.resource.ResourceException;
import javax.resource.cci.Connection;
import javax.resource.cci.ConnectionFactory;
import javax.resource.cci.Interaction;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ebs.cics.copybook.T060.T060REQUEST;
import com.ebs.cics.copybook.T060.T060RESPONSE;
import com.ibm.connector2.cics.ECIInteractionSpec;

/**
 * Servlet implementation class CICSServlet1
 */
@WebServlet("/CICSServlet1")
public class CICSServlet1 extends HttpServlet {
    private static final long serialVersionUID = 1L;

    @Resource(lookup="eis/cicsECI_CF")
    private ConnectionFactory cf = null;


    /**
     * @see HttpServlet#HttpServlet()
     */
    public CICSServlet1() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        T060REQUEST t060Req = new T060REQUEST();
        t060Req.setAccountNumber("10917683");
        t060Req.setApplication("ST");
        t060Req.setTransactionId("T060");


        T060RESPONSE t060Resp = new T060RESPONSE();
        try {
            Connection eciConn = cf.getConnection();
            Interaction eciInt = eciConn.createInteraction();


            // Setup the interactionSpec.
            ECIInteractionSpec eSpec = new ECIInteractionSpec();
            eSpec.setCommareaLength(8000);
            //eSpec.setReplyLength(20);
            eSpec.setFunctionName("EBOT060");
            eSpec.setInteractionVerb(ECIInteractionSpec.SYNC_SEND_RECEIVE);

            eciInt.execute(eSpec, t060Req, t060Resp);
            //eciInt.execute(eSpec, t060Req, t060Resp);
            /*System.out.println("return code is:");
            System.out.println(t060Resp.getReturnCode());

            icbResp.setResp__code(Short.toString(t060Resp.getReturnCode()));
            icbResp.setResp__text(t060Resp.getReturnText());*/
        } catch (ResourceException e) {
            e.printStackTrace();
            //throw e;
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }


        response.getWriter().append("Resp: ").append(Short.toString(t060Resp.getReturnCode())).append(", text: ").append(t060Resp.getReturnText());
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }

}

我得到的解释是:

[err] com.ibm.connector2.cics.CICSUserInputException: CTG9628E InteractionSpec passed to execute() not of type ECIInteractionSpec
[err]   at com.ibm.connector2.cics.ECIInteraction.execute(Unknown Source)
[err]   at com.ebs.jca.web.CICSServlet1.doGet(CICSServlet1.java:62)
[err]   at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
[err]   at [internal classes]
[err]   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[err]   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[err]   at java.lang.Thread.run(Thread.java:748)

我的服务器.xml如下:

<server description="new server">

    <!-- Enable features -->
     <featureManager>
        <feature>localConnector-1.0</feature>
        <feature>javaee-7.0</feature>
        <feature>jca-1.7</feature>
    </featureManager>

    <keyStore id="defaultKeyStore" password="{xor}NDomDCswLToPKDs="/>

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

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


    <library id="ebsPropertiesFiles">
       <folder dir="C:\ICBFiles\Properties\EBS\"/>
    </library>

    <!--The location of the cicseci.rar needs to be updated to the full path-->
   <resourceAdapter autoStart="true" id="eciResourceAdapter" location="C:\ICBFiles\SharedLibs\cicseci9002.rar"/>

   <connectionFactory id="cicsECI_CF" jndiName="eis/cicsECI_CF">
      <!--The properties need to be updated to the location of the CICS Transaction Gateway-->
      <properties.eciResourceAdapter ServerName="CICSQ2V5" connectionUrl="tcp://EBS-WSDEV2-2012.ad.xxx.pri" portNumber="2006"/>
   </connectionFactory>


    <applicationMonitor updateTrigger="mbean"/>


    <webApplication id="jca-web" location="jca-web.war" name="jca-web"/>
</server>

我的POM是:

<?xml version="1.0" encoding="UTF-8"?>
<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>https://raw.github.com/WASdev/ci.maven.tools/master/LICENSE</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <modelVersion>4.0.0</modelVersion>

  <groupId>com.ebs.jca</groupId>
  <artifactId>jca-web</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>

  <name>jca-web</name>
  <url>http://maven.apache.org</url>

  <dependencies>
        <dependency>
            <groupId>net.wasdev.maven.tools.targets</groupId>
            <artifactId>liberty-target</artifactId>
            <version>RELEASE</version>
            <type>pom</type>
            <scope>provided</scope>
        </dependency>

    <dependency>
      <groupId>com.ibm.websphere.ws</groupId>
      <artifactId>wsadie.marshall</artifactId>
      <version>1.0.0</version>
      <type>jar</type>
     <!--  <scope>provided</scope> -->
    </dependency>
    <dependency>
      <groupId>com.ebs.cics.copybooks</groupId>
      <artifactId>T060</artifactId>
      <version>1.2.0</version>
      <type>jar</type>
    </dependency>

    <dependency>
      <groupId>javax.resource</groupId>
      <artifactId>javax.resource-api</artifactId>
      <version>1.7.1</version>
    </dependency>   
   <dependency>
    <groupId>com.ibm.cicseci</groupId>
      <artifactId>cicseci</artifactId>
      <version>9.0.0</version>
      <type>jar</type>

    </dependency>    
    <dependency>
    <groupId>com.ibm.cicseci</groupId>
      <artifactId>cicsframe</artifactId>
      <version>9.0.0</version>
      <type>jar</type>

    </dependency>  

  </dependencies>

  <build>
    <finalName>${project.name}</finalName>
    <plugins>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.1.1</version>
        <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.0.2</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

当我搜索错误代码时。IBM文档声明:https://www . IBM . com/support/knowledge center/en/SSZHFX _ 9 . 2 . 0/ctg 9628 e . html

“检查您的Java客户端应用程序。有关详细信息,请参考产品文档。

我已经阅读了以下教程,但是它们并没有展示一个完整的构建环境。https://developer . IBM . com/CICS/2014/05/06/using-JCA-with-the-CICS-TG-in-WebSphere-liberty-profile/https://github.com/cicsdev/cicstg-jca-liberty-sample

我在使用示例代码时也遇到了同样的错误。

我还尝试按照此链接中的描述设置一个ConnectionFactory:

https://www.ibm.com/support/knowledgecenter/SSGMCP_5.3.0/com.ibm.cics.ts.java.doc/topics/dfhpj2_jca_remote_eci_devconfig.html

当我设置connectionFactory时,如图所示:

<connectionFactory id="com.ibm.cics.wlp.jca.local.eci" jndiName="eis/ECI">
    <properties.com.ibm.cics.wlp.jca.remote.eci serverName="CICSQ2V5" connectionUrl="tcp://EBS-WSDEV2-2012.ad.xxxx.pri" portNumber="2006"/>
   </connectionFactory>

依赖关系注入中断。

CWNEN0030E: The server was unable to obtain an object instance for the java:comp/env/com.ibm.ctg.samples.liberty.JCAServlet/cf reference.  The exception message was: CWNEN1003E: The server was unable to find the eis/ECI binding with the javax.resource.cci.ConnectionFactory type for the java:comp/env/com.ibm.ctg.samples.liberty.JCAServlet/cf reference.

多谢

共有2个答案

董翰池
2023-03-14

发布我为解决问题所遵循的流程。正如特里拉里奥和克什恩伯恩所说,显然存在阶级版本冲突。

谢谢你的帮助。

1安装新的Liberty配置文件。

2出于编译目的,从RAR档案中提取cics.jar。

3不要在server.xml中包含jcaRemoteEci-1.0特性。

4使用以下server.xml:

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

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

    <!-- Encoded password can be generated using bin/securityUtility -->
    <keyStore password="change1me"/>

    <basicRegistry id="basic" realm="BasicRealm">
        <user name="user1" password="change1me"/>
    </basicRegistry>

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

    <library id="ebsPropertiesFiles">
       <folder dir="C:\\ICBFiles\\Properties\\EBS" />
    </library>

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

    <!--The location of the cicseci.rar needs to be updated to the full path-->
    <resourceAdapter autoStart="true" id="eciResourceAdapter" location="C:\ICBFiles\SharedLibs\cicseci9200.rar"/>

    <connectionFactory id="cicsECI_CF" jndiName="eis/cicsECI_CF">
        <!--The properties need to be updated to the location of the CICS Transaction Gateway-->
        <properties.eciResourceAdapter connectionUrl="tcp://EBS-WSDEV2-2012.ad.aib.pri" portNumber="2006" ServerName="CICSUWV5"/>
    </connectionFactory>

    <enterpriseApplication id="icb-liberty-ear" location="icb-liberty-ear.ear" name="icb-liberty-ear">
       <classloader commonLibraryRef="ebsPropertiesFiles" classProviderRef="eciResourceAdapter"/>
    </enterpriseApplication>
</server>

4使用下面的pom.xml。注意,cicseci是用“provided”范围定义的,允许编译器依赖,但要避免打包到war档案中。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>com.icb</groupId>
    <artifactId>icb-liberty</artifactId>
    <version>1.0</version>
  </parent>

  <artifactId>icb-liberty-war</artifactId>
  <packaging>war</packaging>

  <name>ICB WAR Module</name>

  <properties>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <log4j.version>2.8.2</log4j.version>
    <apache.commons.version>3.5</apache.commons.version>
  </properties>

  <dependencies>

    <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-api</artifactId>
      <version>7.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>    
    <dependency>
    <groupId>com.ibm.cicseci</groupId>
      <artifactId>cicseci</artifactId>
      <version>9.0.0</version>
      <type>jar</type>
      <scope>provided</scope>
    </dependency>    
    <dependency>
      <groupId>com.ibm.websphere.ws</groupId>
      <artifactId>wsadie.marshall</artifactId>
      <version>1.0.0</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>com.ebs.cics.copybooks</groupId>
      <artifactId>LAICBRES</artifactId>
      <version>1.0.0</version>
      <type>jar</type>
    </dependency>
  </dependencies>

  <build>
    <finalName>icb-liberty-war</finalName>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.2.0</version>
        <configuration>         
          <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
          <packagingExcludes>pom.xml</packagingExcludes>
          <warName>icb-liberty-war</warName>
          <fileNameMapping>no-version</fileNameMapping>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
林修雅
2023-03-14

查看您的< code>server.xml配置,web应用程序没有从资源适配器加载InteractionSpec类所需的< code>classloader定义。

因此,应将其指定为

<webApplication id="jca-web" location="jca-web.war" name="jca-web">
   <classloader classProviderRef="eciResourceAdapter" />
</webApplication>
 类似资料:
  • 《自由软件,自由社会:理查德·斯托曼选集》Free Software, Free Society: Selected Essays of Richard M. Stallman是一本指导了无数人的书籍,它将理查德·斯托曼的自由软件哲学和思想,阐述的淋漓尽致。 此书第一版首发于 2002 年。也是在 2002 年,北京 GNU/Linux 用户组(BLUG)成立了,经过十多年的发展壮大,已经成为中国

  • 绘图工具是指可以直接操作 Highcharts 的渲染层并绘制基础的图形,例如直接在图表中添加 圆形、矩形、路径或文字,甚至是独立于图表的图形。 在主流的浏览器中绘图工具对象是 SVG 的封装,对应的在低版本 IE (IE8 以下)中是 VML 封装。 已经实例化的图表对象可以通过 chart.renderer 来获取绘图工具对象,如果需要独立图表的绘图工具对象,请通过 var renderer

  • 在范畴理论中,一个单子是两个伴随函子的组合。例如,也许单子是由遗忘函子组成的自由点集函子。同样地,列表单子是由遗忘函子组成的自由么半函子。 半群是最简单的代数结构之一,所以我想知道编程是否可以从更复杂的结构中受益。我在标准的Haskell包中没有找到免费的组单子,所以我将在这里定义它 自由环和向量空间(它们总是自由的)呢? 对于任何代数结构,一个范畴自由函子的存在意味着Haskell调用fold的

  • 我有一个客户在Azure Kubernetes服务上使用open liberty。它们有一个server.xml,使用该机制引用属性文件。他们的设置类似于这个问题: java - WAS Liberty profile - 使用 ClassLoader.getSystemResourceAsStream 读取属性 - Stack Overflow 我的相关问题是:如何让 scanInterval

  • 我想在 liberty 应用程序服务器上激活自定义消息侦听器。 这是我的代码: 这是服务器。xml: 以及我的激活规范: ra.xml: Liberty应用程序服务器在控制台上显示该日志: 出站资源适配器工作正常,但入站没有接收到任何消息!< br >在提出此问题之前,我阅读了此链接,但不明白如何解决此问题:< br >链接1 链接2 链接3 配置/代码的哪个部分有问题? 更新:< br >我将配

  • 在Swoole::$php->runMVC() 调用之前可以修改默认的路由函数。 Swoole::$php->router(function(){ return array('controller' => 'YourController', 'view' => 'YourView'); }); Swoole::$php->runMVC(); 设置后将使用制定的函数作为路由,路由函数务必要