AW_JAVA (JAVA) jobs failing with NoClassDefFoundError java error.

Document ID : KB000090432
Last Modified Date : 14/04/2018
Show Technical Document Details
Issue:
AW_JAVA (JAVA) jobs failing with NoClassDefFoundError java error.
Resolution:

Applicable to ApplicationsManager Versions:  v7.1,v8.0



Detailed Description and Symptoms:

?When Java jobs are requested in Applications Manager 8.0, most commonly using the standard AW_JAVA Program Type, they sometimes fail with 'NoClassDefFoundError' messages. 



Investigation:

?The error mentioned was seen in the output file for the jobs. An example of an error message is below:

Exception in thread "main" java.lang.NoClassDefFoundError: connections/ConnectionManager
 at java.lang.ClassLoader.defineClass1(Native Method)
 at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
 at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
 at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
 at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
 at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)



Solution:

?This issue is seen because the Applications Manager requires and sets certain environment variables during runtime itself. Even though the job runs successfully from the command line (shell) after setting the AM environment using sosite.bat (or sosite) it fails from inside of AM because the additional environment variable(s) may overwrite the custom value(s) required by the Java job.

In order to fix this issue, unsetting the 'CLASSPATH' variable works well. This followed by setting the value of the custom 'CLASSPATH' (if required) resolves the issue. The two commands can be added using a PREFIX script specific to the job in the $AW_HOME\exec directory of the Agent where the job runs. The name of the file would be 'PREFIX.JOB_NAME' where 'JOB_NAME' is the name of the job in AM. The contents of the file would be as follows:

> cat PREFIX.JOB_NAME

unset CLASSPATH

export CLASSPATH="\custom\value\for\classpath"

 

The "\custom\value\for\classpath" would be the custom value as required for the job per the scripter/developer of the same.