No mvsCommandThread active

General discussion on the JZOS batch launcher and toolkit
Post Reply
prichard
Posts: 5
Joined: Fri Jan 09, 2009 8:43 am

No mvsCommandThread active

Post by prichard »

i tried to execute the sample ConsoleInteractionExample sample program from SG247291 3.4.3 JZOS console communication example, and it fails with rc=124. I 've already used JZOS batch successfully with many different sample java applications.
the error i get is :
JZOSVM50(N): Java Virtual Machine created. Version information follows:
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build pmz31devifx-20070617 (S
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 z/OS s390-31 j9vmmz3123ifx-20070616
J9VM - 20070614_12948_bHdSMr
JIT - 20070419_1806_r8
GC - 200704_19)
JZOSVM50(I): Using output encoding: 'IBM-1047'
JZOSVM50(I): MVS commands are ENABLED
JZOSVM50(I): Java main class: com.ibm.jzos.ConsoleInteraction
JZOSVM50(N): Invoking com.ibm.jzos.ConsoleInteraction.main()
Exception occurred invoking com.ibm.jzos.ConsoleInteraction.main()

Exception in thread "main"
JZOSVM50(I): Calling System.exit()...
JZOSVM - failed. RC=124.
Initial msg: My original message from JCL

java.lang.IllegalStateException: No mvsCommandThread active - callback cannot be set
at com.ibm.jzos.MvsConsole.registerMvsCommandCallback(MvsConsole.java:139)
at com.ibm.jzos.ConsoleInteraction.main(ConsoleInteraction.java:29) .
my jcl is :
//PRICHAR1 JOB (PRICHAR),'JZOS',CLASS=A,MSGCLASS=X,
// NOTIFY=&SYSUID,REGION=0M,MSGLEVEL=1
//PROCLIB JCLLIB ORDER='SYS1.JZOS.JCL'
//******************************************************
//*
//*
//JAVA EXEC PROC=EXJZOSVM,
// VERSION='50',
// LOGLVL='+I',
// JAVACLS='com.ibm.jzos.ConsoleInteraction'
//STDENV DD DSN=SYS1.JZOS.JCL(ENV),DISP=SHR
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//STDIN DD *
My original message from JCL
/*
EXJZOSVM is ass follows:

//EXJZOSVM PROC JAVACLS=, < Fully Qfied Java class..RQD
// ARGS=, < Args to Java class
// LIBRARY='SYS1.JZOS125.LOADLIB',
// VERSION='50', < JZOSVM version: 13, 14, 50
// LOGLVL='', < Debug LVL: +I(info) +T(trc)
// REGSIZE='0M', < EXECUTION REGION SIZE
// LEPARM=''
//JAVAJVM EXEC PGM=JZOSVM&VERSION,REGION=&REGSIZE,
// PARM='&LEPARM/&LOGLVL &JAVACLS &ARGS'
//STEPLIB DD DSN=&LIBRARY,DISP=SHR
//SYSPRINT DD SYSOUT=* < System stdout
//SYSOUT DD SYSOUT=* < System stderr
//STDOUT DD SYSOUT=* < Java System.out
//STDERR DD SYSOUT=* < Java System.err
//CEEDUMP DD SYSOUT=*
//ABNLIGNR DD DUMMY
//*
//*The following DDs can/should be present in the calling JCL
//*
//*STDIN DD < OPTIONAL - Java System.in
//*STDENV DD < REQUIRED - JVM Environment script
//*MAINARGS DD < OPTIONAL - Alternate method to supply
// PEND

SYS1.JZOS.JCL(ENV) is:

###########################################################
# Customize below to match your installation:
# JAVA_HOME - The location of the SDK
# JZOS_HOME - The location of the JZOS alphaworks preview
###########################################################
#xport JAVA_HOME=/usr/lpp/java142/J1.4
export JAVA_HOME=/usr/lpp/zWebSphere/V6R1/java/J5.0
#xport JAVA_HOME=/usr/lpp/zWebSphere/V6R1/java64/J5.0_64
JZOS_HOME=/usr/local/jzos
export APP_HOME=/var/jzos
export PATH=/bin:"${JAVA_HOME}"/bin:

LIBPATH=/lib:/usr/lib:"${JAVA_HOME}"/bin
LIBPATH="$LIBPATH":"${JAVA_HOME}"/bin/classic
LIBPATH="$LIBPATH":"${JZOS_HOME}"
export LIBPATH="$LIBPATH":

# Uncomment the following to add additional required jars to CLASSPATH
for i in "${APP_HOME}"/*.jar; do
CLASSPATH="$CLASSPATH":"$i"
done
# Add JZOS required jars to end of CLASSPATH
for i in "${JZOS_HOME}"/*.jar; do
CLASSPATH="$CLASSPATH":"$i"
done

export CLASSPATH="$CLASSPATH"
# Set JZOS specific options
# Use this variable to specify encoding for DD STDOUT and STDERR
#export JZOS_OUTPUT_ENCODING=IBM-1047
# Use this variable to prevent JZOS from handling MVS operator commands
#export JZOS_ENABLE_MVS_COMMANDS=false
# Use this variable to supply additional arguments to main
#export JZOS_MAIN_ARGS=""

# Configure JVM options
IJO="-Xms16m -Xmx128m"
# Uncomment the following if you want to run with Ascii file encoding..
#IJO="$IJO -Dfile.encoding=ISO8859-1"
# Shared class option
IJO="$IJO -Xscmx25m -Xshareclasses:name=MyCache"
# Uncomment the following to aid in debugging "Class Not Found"
# problems
#IJO="$IJO -verbose:class"
IJO="$IJO -Djzos.home=${JZOS_HOME}"
# Uncomment the following if you want to run without JIT
#IJO="$IJO -Djava.compiler=NONE"
export IBM_JAVA_OPTIONS="$IJO "

export JAVA_DUMP_HEAP=false
export JAVA_PROPAGATE=NO
export IBM_JAVA_ZOS_TDUMP=NO

the jar was created and deployed under eclipse sucessfully.
see the source below:
***************************************************
package com.ibm.jzos;
import com.ibm.jzos.MvsCommandCallback;
import com.ibm.jzos.MvsConsole;
import com.ibm.jzos.ZUtil;
import java.io.*;
public class ConsoleInteraction {
public static String msg = null;
public static String msgs[] = {"Hello World!",
"Hello from Montpellier!",
"Hello from ConsoleInteraction!"};
public static String unknownMsg = "Invalid! type [0, 1, or 2]";
public static void main(String arg[]) throws IOException {
byte inputBuf[] = new byte[1000];
int n;
// Receive the initial message to print from the standard input.
n = System.in.read(inputBuf);
if (n > 0) {
String enc = ZUtil.getDefaultPlatformEncoding();
msg = new String(inputBuf, 0, n, enc);
} else {
msg = "No message read from the standard input";
}
System.out.println("Initial msg: " + msg);
// Write to the system log that the system is ready
// to accept commands.
MvsConsole.wto("CIE00001: Ready to accept commands.",
0x0020, 0x4000);
//Test START and MODIFY command.
MvsConsole.registerMvsCommandCallback(new MvsCommandCallback() {
public void handleModify(String s) {
System.out.println("Received command [" + s + "]");
if (s.equals("0")) {
msg = msgs[0];
} else if (s.equals("1")) {
msg = msgs[1];
} else if (s.equals("2")) {
msg = msgs[2];
} else {
msg = unknownMsg;
}
}
public void handleStart(String s) {
}
public boolean handleStop() {
return true;
}
});
// Loop forever to print the selected message.
for (int i = 0;;) {
System.out.println(i++ + ": " + msg);
try {
Thread.sleep(10000);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

Any idea what i am missing here ?
i have tested and run other projects without any pb

i have tried using another sample which implements MVS console interaction, but when i run your MvsConsoleInteraction sample, i get the follwoing error:
JZOSVM50(N): Copyright (C) IBM Corp. 2006. All rights reserved.
JZOSVM50(N): Version 1.2.5
JZOSVM50(N): Java Virtual Machine created. Version information follows:
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build pmz31devifx-20070617 (SR
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 z/OS s390-31 j9vmmz3123ifx-20070616
J9VM - 20070614_12948_bHdSMr
JIT - 20070419_1806_r8
GC - 200704_19)
JZOSVM50(N): Invoking com.ibm.jzos.MVSConsoleInteraction.main()
Check system console for messages.
Exception in thread "Thread-3" java.lang.RuntimeException: com.ibm.jzos.ErrnoException: EDC5157I An internal error has occurred. ERRNO=157 ERRNO2=93e0025
at com.ibm.jzos.MvsConsole$MvsCommandListener.run(MvsConsole.java:81)
Caused by: com.ibm.jzos.ErrnoException: EDC5157I An internal error has occurred.
at com.ibm.jzos.MvsConsole.console2(Native Method)
at com.ibm.jzos.MvsConsole.interact(MvsConsole.java:265)
at com.ibm.jzos.MvsConsole.waitForCmd(MvsConsole.java:233)
at com.ibm.jzos.MvsConsole$MvsCommandListener.run(MvsConsole.java:48)

in the console i do get
Java console interaction: 297
f PRICHAR1,APPL=(DSN | EXIT)
p PRICHAR1
but it will not accept any input (F or P)
i have to cancel it

Thanks for your help
coz
Posts: 391
Joined: Fri Jul 30, 2004 5:29 pm

Post by coz »

It looks like you are using a pre-product version of JZOS (1.2.5). However, from your job output, you are using a version of the Java SDK that has JZOS included - you should be using that version.

Your JCL explicitly sets JZOS_HOME; this is not needed when using the SDK version. I recommend that you start with the sample JCL (JVMJCL50 and JVMPRC50) shipped with the SDK, located at: JAVA_HOME/mvstools/samples/JCL.

In addition, you should use the JZOS launcher shipped with the SDK. This is located at: JAVA_HOME/mvstools/JVMLDM50.

There were significant changes in the console interation code between JZOS version 1.2.5 and 2.0.0 (the first SDK version). If you still have trouble with the samples after making these changes, post back here.
prichard
Posts: 5
Joined: Fri Jan 09, 2009 8:43 am

Post by prichard »

thanks Steve for your quick reply and great help !
i switched to the 2.3.0 alphaworks version, and i got it to work sucessfully for both sample applications.
Unfortunately i only have version of SDK 1.4.2, which does not contain the members you were mentioning (JVMJCL50 and JVMPRC50) in /mvstools/samples/JCL.

i will try SDK 1.5 out of the websphere code in my next tests (which have them...).
Thanks again


JVMJZBL1001N JZOS batch Launcher Version: 2.3.0 Alphaworks 2008-05-12
JVMJZBL1002N Copyright (C) IBM Corp. 2005. All rights reserved.
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build pmz31devifx-20070617 (SR
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 z/OS s390-31 j9vmmz3123ifx-20070616
J9VM - 20070614_12948_bHdSMr
JIT - 20070419_1806_r8
GC - 200704_19)
JVMJZBL1023N Invoking com.ibm.jzos.MVSConsoleInteraction.main()...
JVMJZBL1043N The Java virtual machine completed with System.exit(0)
Check system console for messages.
Finished processing.
Post Reply