Dave:
I agree that the root of the problem is the new AS400().
AS400ConnectionPool manages a pool of AS400 connections.  So new
AS400(...) could be replaced with new
AS400ConnectionPool().getConnection(...)
David Gibbs wrote some time ago:
.. but if you want to use the same job repeatedly with the CommandCall
class, you need to set thread safe to true. This limits the commands 
that can be run (can't run CRTRPGMOD for example), but fits most
situations. You can look at a command using DSPCMD to determine
if it is thread safe.
That might apply in this situation.
-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of Dave Murvin
Sent: Thursday, October 02, 2008 10:42 PM
To: java400-l@xxxxxxxxxxxx
Subject: Program called by PCML not ending
Apologies if this is a duplicate.  I wasn't subscribed (I thought I 
was) and didn't see anything on this in the archives.
Hello;
We have an RPGLE program that is called using PCML from a Java 
application by  a software vendor.  The call to the RPGLE program 
results in a server job being started that then calls the RPGLE 
program.  The RPGLE program does it's thing and returns information 
to the calling Java program.  This all works okay, except the server 
job never ends and each time the vendor calls this pcml program, it 
starts another server job.  There are hundreds of these jobs and we 
have to bring down the subsystem to kill them.
What are we or the vendor missing?  I would think that when the job 
ends, it should just go away.
Thanks for the help.
Dave
Server jobs looks like this in wrkactjob:
Opt  Subsystem/Job  User        Type  CPU %  Function        Status
      QUSRWRK        QSYS        SBS      .0                   DEQW
        QZRCSRVS     SHIP_SVC    PJ       .0                   TIMW
        QZRCSRVS     SHIP_SVC    PJ       .0                   TIMW
        QZRCSRVS     SHIP_SVC    PJ       .0                   TIMW
        QZRCSRVS     SHIP_SVC    PJ       .0                   TIMW
        QZRCSRVS     SHIP_SVC    PJ       .0                   TIMW
        QZRCSRVS     SHIP_SVC    PJ       .0                   TIMW
        QZRCSRVS     SHIP_SVC    PJ       .0                   TIMW
        QZRCSRVS     SHIP_SVC    PJ       .0                   TIMW
        QZRCSRVS     SHIP_SVC    PJ       .0                   TIMW
A partial list of the PCML java code:
            sys = new AS400(machName, userID, Password);
            ProgramCallDocument pcml;
            try
            {
                  sys.setGuiAvailable(false);
                  // uncomment lines below for logging (never got 
this to work but kept them
                  // they are from ibm.com example PCML program...
 
//com.ibm.as400.data.PcmlMessageLog.setTraceEnabled(true);
 
//com.ibm.as400.data.PcmlMessageLog.setLogFileName("PCML.log"); 
                  KQLOG.D("Beginning PCML");
                  KQLOG.D("    Constructing ProgramCallDocument for 
PSHPINF API...");
                  // Construct ProgramCallDocument
                  // First parameter is system to connect to
                  // Second parameter is pcml resource name.
                  // PCML source file "pshpinf.pcml" must be found in 
the M3 classpath.
                  pcml = new ProgramCallDocument(sys, "PSHPINF");
                  // set Varsity input parameters
                  HDISH.setCONO(MMUPDREPDS.getM9CONO());
                  HDISH.setINOU(1);
                  HDISH.setDLIX(MMUPDREPDS.getM9RIDI());
                  IN91 = !HDISH.CHAIN("00", HDISH.getKey("00"));
                  // Delivery number DLIX
                  //this.PXNUM = HDISH.getDLIX();
                  //this.PXEDTC = 'L';
                  //this.PXDCFM = LDAZD.DCFM;
                  //this.PXALPH.clear();
                  //SRCOMNUM.COMNUM();
                  XXDLIX.move(HDISH.getDLIX());
                  pcml.setValue("PSHPINF.DELIVERYNO", XXDLIX);
                  //  Package/Carton Number  PANR
 
XXPANR.moveRight(MMUPDREPDS.getM9PACN().toStringRTrim()); 
//BR02002 MICKYB
                  pcml.setValue("PSHPINF.PACKAGENO",  XXPANR);
                  // Total package TPKG
                  // Get Total Package
                  int count = 0;
                  PTRNS.setCONO(HDISH.getCONO()); 
                  PTRNS.setDIPA(0); 
                  PTRNS.setWHLO().move(HDISH.getWHLO()); 
                  PTRNS.setDLIX(HDISH.getDLIX());
                  PTRNS.SETLL("00", PTRNS.getKey("00", 
4));
                  while (PTRNS.READE("00", PTRNS.getKey("00", 4))) {
                        count++;
                  }
                  //this.PXNUM = count;
                  //this.PXDCFM = LDAZD.DCFM;
                  //this.PXALPH.clear();
                  //SRCOMNUM.COMNUM();
                  XXCNT.move(count);
                  pcml.setValue("PSHPINF.TOTALPKGS", XXCNT);
                  // Total Package end
                  // User ID to run RPG program
                  XXUSER.moveLeftPad(this.DSUSS);
                  pcml.setValue("PSHPINF.USERID", XXUSER);
                  pcml.setValue("PSHPINF.TRACKINGNO", EnvName);
                  pcml.setValue("PSHPINF.STATUSCODE", " ");
                  // Call PSHPINF API
                  pcml.callProgram("PSHPINF"); // program 
name   <-----  Dave this is the call right here.   Above setups up 
the parameters, below here is the return processing....
                  // Returned values from PSHPINF API
                  StatusCode = (String)
pcml.getValue("PSHPINF.STATUSCODE");
                  ShipperTrackerNo = (String) 
pcml.getValue("PSHPINF.TRACKINGNO");
            }
            catch (PcmlException pe)
            {
                  String err =  pe.getMessage();
                  if (err.length() > 50)
                  {
                        ShipperTrackerNo = 
err.substring(err.length()-50, err.length());
                  }
                  else
                  {
                        ShipperTrackerNo = err;
                  }
                  StatusCode = "1";
                  IN60 = true;
                  this.MSGDTA.moveLeftPad(pe.getMessage());
                  this.MSGID.moveLeftPad("CPF9898");  // Package 
number &1 does not exist.
            }
            catch (Exception pe)
            {
                  String err =  pe.getMessage();
                  if (err.length() > 50)
                  {
                        ShipperTrackerNo = 
err.substring(err.length()-50, err.length());
                  }
                  else
                  {
                        ShipperTrackerNo = err;
                  }
                  StatusCode = "1";
                  IN60 = true;
                  this.MSGDTA.moveLeftPad(pe.getMessage());
                  this.MSGID.moveLeftPad("CPF9898");  // Package 
number &1 does not exist.
            }
            varStatus.move(StatusCode);
            KQLOG.D("Varsity user:   " + XXUSER);
            KQLOG.D("Varsity status code returned 0=OK  1=Error:   " 
+ varStatus);
            KQLOG.D("Varsity tracking number:   " + ShipperTrackerNo);
            // Display error if found
            if (StatusCode == "1") {
                  IN60 = true;
                  this.MSGDTA.moveLeftPad(ShipperTrackerNo);
                  this.MSGID.moveLeftPad("CPF9898");  // Package 
number &1 does not exist.
            }
            // Update ETRN with varsity number returned
            PTRNS.setCONO(HDISH.getCONO()); 
            PTRNS.setDIPA(0); 
            PTRNS.setWHLO().move(HDISH.getWHLO()); 
            PTRNS.setDLIX(HDISH.getDLIX());
            PTRNS.setPANR().moveLeftPad(MMUPDREPDS.getM9PACN());
            IN91 = !PTRNS.CHAIN_LOCK("00", PTRNS.getKey("00"));
            if (!IN91) {
                  PTRNS.setETRN().moveLeftPad(ShipperTrackerNo);
                  PTRNS.UPDAT("00");
            }
      }      // ZVARSITY END B
Dave Murvin
DRM Enterprises, Inc.
As an Amazon Associate we earn from qualifying purchases.