I am trying to use the JCA and CICSECI functionality to connect to IBM Mainframe via the CICS Transaction Gateway.
My Servlet code is:
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);
}
}
The exeption that I am getting is:
[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)
My server.xml is as follows:
<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>
And my POM is:
<?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>
When I google the error code. The IBM docs state: https://www.ibm.com/support/knowledgecenter/en/SSZHFX_9.2.0/CTG9628E.html
"Review your Java client application. Refer to the product documentation for further details."
I have reviewed the following tutorials but they do not show a complete build environment. 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
And I get the same error when using the sample code.
I have also tried to setting up a connectionFactory as described in this link:
https://www.ibm.com/support/knowledgecenter/SSGMCP_5.3.0/com.ibm.cics.ts.java.doc/topics/dfhpj2_jca_remote_eci_devconfig.html
When I set up a connectionFactory as shown:
<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>
the dependency injection breaks.
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.
Many Thanks