Exception Handling of Java Method Calls

Each exception that is not handled by the invoked Java method itself is thrown to the BDL script where a native Java error is raised. The raised error contains the name of the exception class and the exception message. However, the raised error does not contain the stack trace of the exception.

The exception stack trace, which belongs to the native Java error, is written to the virtual user log file.

  JavaCallMethod()
  {
    handle       = 0x012fdde8  
    Meth. name   = "doFakeScenario" 
    return value = false 
    Exception    = "java.lang.RuntimeException: something unexpected thrown in my java code
	at Test.anotherSubMethod(Test.java:40)
	at Test.aSubMethod(Test.java:35)
	at Test.doFakeScenario(Test.java:47)
" 
  }

Developers often rely on output written to the command console when debugging Java applications. When doing a Try Script run, all command console output of the Java application is captured as RepMessage with severity informational. These messages can be viewed in the VU output console and the virtual user report file.

Advanced Exception Handling

Each exception that is not caught by the Java test driver is thrown to the BDL script, where an error under facility Native Java (1007) is raised. In most cases the error subcode is 0. To distinguish different Java exceptions in BDL, error subcodes can be assigned to specific exception messages. Use JavaRegisterException to assign an error subcode to a specific Java exception. These error subcodes can be helpful for other BDL functions, such as ErrorAdd, which can be used to change the severity of errors.