Can I get the cause of an exception using Java 1.3.1?

Simple enough question, but is it possible :/ I Must use 1.3.1 for compatibility with other products (i.e. websphere) but I'm not sure if this is possible. If I need another class to do it then that's fine.

Thanks in advance for your help :)
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

aozarovConnect With a Mentor Commented:
Have a look at
This is the source code for LocationInfo which is used by log4j determine which class / method / line was throwing the exception. (to be compatible with 1.3
that doesn't have the getStackTrace method (since 1.4). you can use similar logic to pick the line you code that you have interest in.
Will e.getMessage() work?

What do you mena by root cause exactly?
or e.getCause() ;
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

No, getCause() is 1.4 isn't it...
CEHJConnect With a Mentor Commented:
yeggstryAuthor Commented:
OK, in the system I am using it throws an error where the e.getMessage() is:

Unable to connect: com.ncode.gdm.command.NCCommandException: Error running process.

BUT there are two possible causes for this message to be thrown....

Could not get the path of the filestore root directory.


Unable to find process(core22_GetSystemParameters)

at the moment I am using e.getCause() to get it, but that is not 1.3.1 compatible :/

Any ideas?
yeggstryAuthor Commented:
I also need just the cause message, not the whole stacktrace (the error is being displayed on the screen for the user).
bloodredsunConnect With a Mentor Commented:
I think that CEHJ is right and you'll have to use  e.printStackTrace() and parse out the answer yourself.
yeggstryAuthor Commented:
dammit that sucks :/ ok, so how would I manipulate the stack trace to get the cause? Could I use regular expressions and if so how could I get the stackTrace into something I can work with?
yeggstryAuthor Commented:
Yup, that's great :) thanks

I've managed to compress it down to what I need, at its simplist form you can do:

            StringWriter sw = new StringWriter();
            ex.printStackTrace(new PrintWriter(sw));
            String stacktrace = sw.toString();
            System.out.println("stacktrace = " + stacktrace);

which is exactly what I need to do my regular expressions :)

Thanks for your help guys.
All Courses

From novice to tech pro — start learning today.