× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Carl wrote:
Hello,

I am curious if there is a way to catch Java exceptions when calling a
Java method from within RPG, or retrieve the message/stack trace. I am
currently using the RPG MONITOR/ON-ERROR/ENDMON construct, and calling
DUMP when an exceptions is thrown, but the output simply states "Java
exception received when calling Java method", Not very helpful.

Any suggestions are appreciated.
Carl.

You could receive the RNX0301 message to get the first 100 bytes of the Java exception.

If you're on V5R3+, you can get the Java stack trace to stderr if you have environment variable QIBM_RPG_JAVA_EXCP_TRACE set to 'Y'.

If you're running in batch, you can probably see the exception trace in a QPRINT file when the job ends. Otherwise, you'll probably want to get the stack trace put out to a file, and you'll need to do a few more steps:
1. Have environment variable QIBM_USE_DESCRIPTOR_STDIO set to 'Y', before you start the JVM.
2. Have Java property os400.stderr set to point to the file you want, before you start the JVM.
3. Ensure 3 descriptors are open in your job before Java does any I/O,
including writing your exception trace to stderr. See these threads in the archives. (Don't worry that the thread title says STRDBG; the actual threads are directly on point for opening the 3 descriptors.)
http://archive.midrange.com/midrange-l/200605/threads.html#01505
http://archive.midrange.com/midrange-l/200606/threads.html#00087


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.