ClassNotFoundException and AJ07 running CICS Java application after copying a JAR from a PC to a mainframe
You receive an abend AJ07 with ClassNotFoundException when trying to run a Java™ application using CICS Transaction Server. The class that the JVM can not find is in a JAR file that you create with VisualAge for Java on your PC. You use FTP to transfer the JAR file from your PC directly into the to the hierarchical file system (HFS) on the mainframe.
You also try to use IND$FILE to send the JAR file to the mainframe and then use TSO ISHELL to copy it to the HFS.
Even though you receive the abend AJ07, the JAR file can still be read by the OMVS jar command jar tf jar-file.jar. The JVM can also successfully load the class from the HFS if the JAR is unpacked.
By default, FTP opens the data connection in ASCII mode instead of binary mode and IND$FILE creates the dataset on the mainframe with RECFM=FB and LRECL=80.
Resolving the problem
If using FTP, specify binary when doing the transfer of the JAR. Following is an example of the commands you can enter from Windows® to copy a file directly from your PC into the HFS:
- Start a Windows command prompt.
- Enter cd dir-name to the directory containing the jar file.
- Enter ftp ip-address to connect to your Host. You can enter netstat home from TSO to find out your host ip-address. It will be the first ip-address listed
- Enter your userid to logon. You might have to enter user userid.
- Enter your password.
- Enter bin so that the file transfer will be done in binary.
- Enter cd dir-name where dir-name is the directory name on the Host . For example, cd /u/userid/test/directory.
- Enter put jar-name.jar to copy the JAR into the HFS from your PC.
- Enter quit to exit FTP
If using IND$FILE, pre-allocate a dataset on the mainframe with RECFM=VB and LRECL=256 before entering the send command. Also, ensure that you specify binary if using TSO ISHELL to copy the JAR file into the HFS.
Here is what the Data Set Information when viewed with TSO option 3.4 should look like:
Data Set Name . . . . : USERID.TEST.JAR
Management class . . : E02YBYRY
Storage class . . . : STANDARD
Volume serial . . . : P1P110
Device type . . . . : 3390
Data class . . . . : **None**
Organization . . . : PS
Record format . . . : VB
Record length . . . : 256
Block size . . . . : 6233
1st extent tracks . : 1
Secondary tracks . : 1
Data set name type :
Creation date . . . : 2004/09/17
Expiration date . . : ***None***
CICS/TS CICS TS CICS Transaction Server