Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Java Exception not Caught

4 posts in EJB Client Last posting was on 2007-09-17 15:54:15.0Z
Brett Birschbach Posted on 2007-09-11 14:57:39.0Z
Sender: 575c.46e6aa82.1804289383@sybase.com
From: Brett Birschbach
Newsgroups: sybase.public.powerbuilder.ejbclient
Subject: Java Exception not Caught
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <46e6ace3.57af.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 11 Sep 2007 07:57:39 -0700
X-Trace: forums-1-dub 1189522659 10.22.241.41 (11 Sep 2007 07:57:39 -0700)
X-Original-Trace: 11 Sep 2007 07:57:39 -0700, 10.22.241.41
Lines: 34
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.ejbclient:763
Article PK: 424863

Scenario:

Java Classes:
com.pbtest.ParentException extends java.lang.Exception
com.pbtest.ChildException extends com.pbtest.ParentException

PB Proxies:
ParentException extends Exception
ChildException extends ParentException

PB Code:
TRY
// DO SOME JAVA CODE THAT THROWS ChildException
CATCH (ParentException pe)
// Save the day
END TRY

In the above example, if the PB project has ParentException
and ChildException proxies, then PB successfully catches
ChildException as a version of ParentException, and "saves
the day".

However, if I do not have a proxy for ChildException, just
ParentException, PB fails to map the java exception
com.pbtest.ChildException to the PB proxy ParentException.
Is this the expected functionality? I would think, through
the use of Java reflection, PB would be able to find the
ancestor of com.pbtest.ChildException as
com.pbtest.ParentException, and thus map it to the
ParentException PB Proxy. However, it does not appear that
it does so.

Thanks!
-Brett Birschbach


bede Posted on 2007-09-12 07:26:31.0Z
From: bede <bedenosp@msofico.be>
Newsgroups: sybase.public.powerbuilder.ejbclient
Subject: Re: Java Exception not Caught
Message-ID: <MPG.2151b315c921da5f9898ad@forums.sybase.com>
References: <46e6ace3.57af.1681692777@sybase.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"
Content-Transfer-Encoding: 7bit
User-Agent: MicroPlanet-Gravity/2.70.2067
NNTP-Posting-Host: uu194-7-38-226.unknown.uunet.be
X-Original-NNTP-Posting-Host: uu194-7-38-226.unknown.uunet.be
Date: 12 Sep 2007 00:26:31 -0700
X-Trace: forums-1-dub 1189581991 194.7.38.226 (12 Sep 2007 00:26:31 -0700)
X-Original-Trace: 12 Sep 2007 00:26:31 -0700, uu194-7-38-226.unknown.uunet.be
Lines: 38
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.ejbclient:765
Article PK: 424864

does it get caught when catching Throwable ?

In article <46e6ace3.57af.1681692777@sybase.com>, Brett Birschbach says...

> Scenario:
>
> Java Classes:
> com.pbtest.ParentException extends java.lang.Exception
> com.pbtest.ChildException extends com.pbtest.ParentException
>
> PB Proxies:
> ParentException extends Exception
> ChildException extends ParentException
>
> PB Code:
> TRY
> // DO SOME JAVA CODE THAT THROWS ChildException
> CATCH (ParentException pe)
> // Save the day
> END TRY
>
> In the above example, if the PB project has ParentException
> and ChildException proxies, then PB successfully catches
> ChildException as a version of ParentException, and "saves
> the day".
>
> However, if I do not have a proxy for ChildException, just
> ParentException, PB fails to map the java exception
> com.pbtest.ChildException to the PB proxy ParentException.
> Is this the expected functionality? I would think, through
> the use of Java reflection, PB would be able to find the
> ancestor of com.pbtest.ChildException as
> com.pbtest.ParentException, and thus map it to the
> ParentException PB Proxy. However, it does not appear that
> it does so.
>
> Thanks!
> -Brett Birschbach
>


Brett Birschbach Posted on 2007-09-13 22:23:13.0Z
Sender: 22db.46e9b736.1804289383@sybase.com
From: Brett Birschbach
Newsgroups: sybase.public.powerbuilder.ejbclient
Subject: Re: Java Exception not Caught
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <46e9b851.22f6.1681692777@sybase.com>
References: <MPG.2151b315c921da5f9898ad@forums.sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 13 Sep 2007 15:23:13 -0700
X-Trace: forums-1-dub 1189722193 10.22.241.41 (13 Sep 2007 15:23:13 -0700)
X-Original-Trace: 13 Sep 2007 15:23:13 -0700, 10.22.241.41
Lines: 55
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.ejbclient:766
Article PK: 424865

Thanks for the suggestion.

Yes, throwable does work, and it will also get caught when
catching Exception. It appears that if PB cannot map a Java
exception to a Java proxy in your PB code, it maps it to a
generic PB Exception.

The problem is, I don't necessarily want to catch any and
all PowerBuilder exceptions from my TRY/CATCH block. I only
want to catch my Java exception. Any other exceptions can
slip throw and be thrown back to the calling code.
Furthermore, I may have three different java exceptions that
I want to catch, with three different sets of handling code.
If I simply catch Exception, I have no idea which java
exception caused it, and therefore no idea which handling
code to run.

> does it get caught when catching Throwable ?
>
> In article <46e6ace3.57af.1681692777@sybase.com>, Brett
> > Birschbach says... Scenario:
> >
> > Java Classes:
> > com.pbtest.ParentException extends java.lang.Exception
> > com.pbtest.ChildException extends
> > com.pbtest.ParentException
> > PB Proxies:
> > ParentException extends Exception
> > ChildException extends ParentException
> >
> > PB Code:
> > TRY
> > // DO SOME JAVA CODE THAT THROWS ChildException
> > CATCH (ParentException pe)
> > // Save the day
> > END TRY
> >
> > In the above example, if the PB project has
> > ParentException and ChildException proxies, then PB
> > successfully catches ChildException as a version of
> > ParentException, and "saves the day".
> >
> > However, if I do not have a proxy for ChildException,
> > just ParentException, PB fails to map the java exception
> > com.pbtest.ChildException to the PB proxy
> > ParentException. Is this the expected functionality? I
> > would think, through the use of Java reflection, PB
> > would be able to find the ancestor of
> > com.pbtest.ChildException as com.pbtest.ParentException,
> > and thus map it to the ParentException PB Proxy.
> > However, it does not appear that it does so.
> >
> > Thanks!
> > -Brett Birschbach
> >


bede Posted on 2007-09-17 15:54:15.0Z
From: bede <bedenosp@msofico.be>
Newsgroups: sybase.public.powerbuilder.ejbclient
Subject: Re: Java Exception not Caught
Message-ID: <MPG.2158c15aab2895199898b0@forums.sybase.com>
References: <MPG.2151b315c921da5f9898ad@forums.sybase.com> <46e9b851.22f6.1681692777@sybase.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"
Content-Transfer-Encoding: 7bit
User-Agent: MicroPlanet-Gravity/2.70.2067
NNTP-Posting-Host: uu194-7-38-226.unknown.uunet.be
X-Original-NNTP-Posting-Host: uu194-7-38-226.unknown.uunet.be
Date: 17 Sep 2007 08:54:15 -0700
X-Trace: forums-1-dub 1190044455 194.7.38.226 (17 Sep 2007 08:54:15 -0700)
X-Original-Trace: 17 Sep 2007 08:54:15 -0700, uu194-7-38-226.unknown.uunet.be
Lines: 29
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.ejbclient:767
Article PK: 424866

In that case i would try to workaround as follows:

- use Catch(Throwable t) (highest common ancestor) and try differentiating with t.ClassName()
- alternatively, use the message to make the difference.

however, i do agree that PB should support catching of specific exceptions thrown from within
the java layer. i think it's best to open a case for this.

Since we've been communicating with EJBs before PB supported java, we still use our own way
to communicate errors (returned classes contain an error section).
What is caught as native exceptions is in our case always coming from PBNI or communication
layer. so we don't really have your particular problem.

Good luck & keep us posted,

Ben


In article <46e9b851.22f6.1681692777@sybase.com>, Brett Birschbach says...

> The problem is, I don't necessarily want to catch any and
> all PowerBuilder exceptions from my TRY/CATCH block. I only
> want to catch my Java exception. Any other exceptions can
> slip throw and be thrown back to the calling code.
> Furthermore, I may have three different java exceptions that
> I want to catch, with three different sets of handling code.
> If I simply catch Exception, I have no idea which java
> exception caused it, and therefore no idea which handling
> code to run.
>