Name is not unique (RTS119) calling when calling webservice twice

I am using VC40 and try to call a cobol programm named PROGRAM1 within a Soap-Webservice using Wildfly 10:

@WebService
public class SoapDemo {

@WebMethod
public Integer doLvdcWith1(boolean print) {

PROGRAM1 program1 = new PROGRAM1();
Copy1 copy1 = new Copy1();

copy1.setEDatum("20190101");
program1.PROGRAM1(copy1);

System.err.println(copy1.getADatum());

return 1;
}
}

Calling the webservice the first time, everything is perfect.

But calling it another time, the call doesn't work:

com.microfocus.cobol.program.COBOLRuntimeException: 119 Name is not unique [de.herbert.PROGRAM1]

I think I found a reason for the crash, but unfortunately no solution:

/cobol/netexservex/w/wikiid-121/9225/rts-119-name-is-not-unique

  • Verified Answer

    I found the solution, I have to use the Rununit ...

    try
    {
    Copy1 copy1 = new Copy1();
    copy1.setEDatum("20190101");
    PROGRAM1 programInstance = new PROGRAM1();
    myRunUnit.addInstance(programInstance);
    programInstance.PROGRAM1(copy1);
    System.err.println(copy1.getADatum());
    }
    finally
    {
    // Destroy the run unit
    myRunUnit.stopRunUnit();
    }