The Source for Java Technology Collaboration

Home » java.net Forums » GlassFish » GlassFish

Thread: exception handling in EJB3 Stateless and JAX -WS. guide tutorial example...

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 8 - Last Post: Jun 23, 2008 4:04 AM by: dnlcy
Mohammad Shamsi
exception handling in EJB3 Stateless and JAX -WS. guide tutorial example...
Posted: May 24, 2008 3:33 AM
  Click to reply to this thread Reply

hi all,

im looking for guides and examples for Exception Handling in EJB3
Stateless Session Bean and JAX WS

any resources ? idea ?




--
sincerely yours
M. H. Shamsi
[att1.html]


Markus Karg
RE: exception handling in EJB3 Stateless and JAX -WS. guide tutorial example...
Posted: May 25, 2008 11:27 PM   in response to: Mohammad Shamsi
  Click to reply to this thread Reply

What exactly do you want to know?



Regards

Markus



From: Mohammad Shamsi [mailto:m.h.shams@gmail.com]
Sent: Samstag, 24. Mai 2008 12:33
To: users@glassfish.dev.java.net
Subject: exception handling in EJB3 Stateless and JAX -WS. guide
tutorial example...



hi all,

im looking for guides and examples for Exception Handling in EJB3
Stateless Session Bean and JAX WS

any resources ? idea ?




--
sincerely yours
M. H. Shamsi

[att1.html]


Mohammad Shamsi
Re: exception handling in EJB3 Stateless and JAX -WS. guide tutorial example...
Posted: May 25, 2008 11:49 PM   in response to: Markus Karg
  Click to reply to this thread Reply

Hi Markus,

In Java EE 5 we can one code for both Session Bean and Web Service.

@WebService
@Stateless
public class FooImpl implements Foo {
public void dofoo() {
}
}

clients can call dofoo method, either via RMI (as a Session Bean) or
SOAP/HTTP (as a web method)

for web service clients i can throw just a SOAPFaultException and for RMI
clients i can throw any exception.

i have to know that how to handle and throw exception from this method that
both clients can use it.



On Mon, May 26, 2008 at 9:57 AM, Markus Karg <karg@quipsy.de> wrote:

> What exactly do you want to know?
>
>
>
> Regards
>
> Markus
>
>
>
> *From:* Mohammad Shamsi [mailto:m.h.shams@gmail.com]
> *Sent:* Samstag, 24. Mai 2008 12:33
> *To:* users@glassfish.dev.java.net
> *Subject:* exception handling in EJB3 Stateless and JAX -WS. guide
> tutorial example...
>
>
>
> hi all,
>
> im looking for guides and examples for Exception Handling in EJB3
> Stateless Session Bean and JAX WS
>
> any resources ? idea ?
>
>
>
>
> --
> sincerely yours
> M. H. Shamsi
>



--
sincerely yours
M. H. Shamsi
[att1.html]


Markus Karg
RE: Re: exception handling in EJB3 Stateless and JAX -WS. guide tutorial example...
Posted: May 26, 2008 2:20 AM   in response to: Mohammad Shamsi
  Click to reply to this thread Reply

AFAIK in your current situation you do not need to worry about specific
exceptions. Just throw all the business exceptions that you need and do
not care for whether the client is using RMI or SOAP. AFAIK @WebServices
is wrapping any business exception sufficiently, so when using JAX-WS on
the client side, you will catch exactly the same Java Exception again --
while beeing *transported* by SOAP. You do not need to throw SOAP or RMI
specific exceptions. Just throw a FooException.



I can remember I tried out months ago and it worked well, but I am no
SOAP guru. Just give it a try and let us know whether it works. :-)



Regards

Markus



From: Mohammad Shamsi [mailto:m.h.shams@gmail.com]
Sent: Montag, 26. Mai 2008 08:50
To: users@glassfish.dev.java.net
Subject: Re: exception handling in EJB3 Stateless and JAX -WS. guide
tutorial example...



Hi Markus,

In Java EE 5 we can one code for both Session Bean and Web Service.

@WebService
@Stateless
public class FooImpl implements Foo {
public void dofoo() {
}
}

clients can call dofoo method, either via RMI (as a Session Bean) or
SOAP/HTTP (as a web method)

for web service clients i can throw just a SOAPFaultException and for
RMI clients i can throw any exception.

i have to know that how to handle and throw exception from this method
that both clients can use it.




On Mon, May 26, 2008 at 9:57 AM, Markus Karg <karg@quipsy.de> wrote:

What exactly do you want to know?



Regards

Markus



From: Mohammad Shamsi [mailto:m.h.shams@gmail.com]
Sent: Samstag, 24. Mai 2008 12:33
To: users@glassfish.dev.java.net
Subject: exception handling in EJB3 Stateless and JAX -WS. guide
tutorial example...



hi all,

im looking for guides and examples for Exception Handling in EJB3
Stateless Session Bean and JAX WS

any resources ? idea ?




--
sincerely yours
M. H. Shamsi




--
sincerely yours
M. H. Shamsi

[att1.html]


Mohammad Shamsi
Re: Re: exception handling in EJB3 Stateless and JAX -WS. guide tutorial example...
Posted: May 26, 2008 2:47 AM   in response to: Markus Karg
  Click to reply to this thread Reply

but i tested it before, result :

1 - FooException is RuntimeException : i got EJBException in JAX WS client
without any clear message or stack trace.

2 - FooException is not RuntimeException : in JAX WS client i got another
exception during FooException.setMessage() method call. (FooException has a
String message)



On Mon, May 26, 2008 at 12:50 PM, Markus Karg <karg@quipsy.de> wrote:

> AFAIK in your current situation you do not need to worry about specific
> exceptions. Just throw all the business exceptions that you need and do not
> care for whether the client is using RMI or SOAP. AFAIK @WebServices is
> wrapping any business exception sufficiently, so when using JAX-WS on the
> client side, you will catch exactly the same Java Exception again -- while
> beeing *transported* by SOAP. You do not need to throw SOAP or RMI specific
> exceptions. Just throw a FooException.
>
>
>
> I can remember I tried out months ago and it worked well, but I am no SOAP
> guru. Just give it a try and let us know whether it works. :-)
>
>
>
> Regards
>
> Markus
>
>
>
> *From:* Mohammad Shamsi [mailto:m.h.shams@gmail.com]
> *Sent:* Montag, 26. Mai 2008 08:50
> *To:* users@glassfish.dev.java.net
> *Subject:* Re: exception handling in EJB3 Stateless and JAX -WS. guide
> tutorial example...
>
>
>
> Hi Markus,
>
> In Java EE 5 we can one code for both Session Bean and Web Service.
>
> @WebService
> @Stateless
> public class FooImpl implements Foo {
> public void dofoo() {
> }
> }
>
> clients can call dofoo method, either via RMI (as a Session Bean) or
> SOAP/HTTP (as a web method)
>
> for web service clients i can throw just a SOAPFaultException and for RMI
> clients i can throw any exception.
>
> i have to know that how to handle and throw exception from this method that
> both clients can use it.
>
>
> On Mon, May 26, 2008 at 9:57 AM, Markus Karg <karg@quipsy.de> wrote:
>
> What exactly do you want to know?
>
>
>
> Regards
>
> Markus
>
>
>
> *From:* Mohammad Shamsi [mailto:m.h.shams@gmail.com]
> *Sent:* Samstag, 24. Mai 2008 12:33
> *To:* users@glassfish.dev.java.net
> *Subject:* exception handling in EJB3 Stateless and JAX -WS. guide
> tutorial example...
>
>
>
> hi all,
>
> im looking for guides and examples for Exception Handling in EJB3
> Stateless Session Bean and JAX WS
>
> any resources ? idea ?
>
>
>
>
> --
> sincerely yours
> M. H. Shamsi
>
>
>
>
> --
> sincerely yours
> M. H. Shamsi
>



--
sincerely yours
M. H. Shamsi
[att1.html]


Mohammad Shamsi
Re: Re: exception handling in EJB3 Stateless and JAX -WS. guide tutorial example...
Posted: May 27, 2008 12:01 AM   in response to: Mohammad Shamsi
  Click to reply to this thread Reply

Hi,

i run a test with netbeans, (a web service client with netbeans) and i stack
trace is :

javax.xml.ws.soap.SOAPFaultException: javax.ejb.EJBException
at...

Caused by: javax.ejb.EJBException
at...

Caused by: FooException: test message
at...

i just throw a FooException in my Web Method.

On Mon, May 26, 2008 at 1:17 PM, Mohammad Shamsi <m.h.shams@gmail.com>
wrote:

> but i tested it before, result :
>
> 1 - FooException is RuntimeException : i got EJBException in JAX WS client
> without any clear message or stack trace.
>
> 2 - FooException is not RuntimeException : in JAX WS client i got another
> exception during FooException.setMessage() method call. (FooException has a
> String message)
>
>
>
>
> On Mon, May 26, 2008 at 12:50 PM, Markus Karg <karg@quipsy.de> wrote:
>
>> AFAIK in your current situation you do not need to worry about specific
>> exceptions. Just throw all the business exceptions that you need and do not
>> care for whether the client is using RMI or SOAP. AFAIK @WebServices is
>> wrapping any business exception sufficiently, so when using JAX-WS on the
>> client side, you will catch exactly the same Java Exception again -- while
>> beeing *transported* by SOAP. You do not need to throw SOAP or RMI specific
>> exceptions. Just throw a FooException.
>>
>>
>>
>> I can remember I tried out months ago and it worked well, but I am no SOAP
>> guru. Just give it a try and let us know whether it works. :-)
>>
>>
>>
>> Regards
>>
>> Markus
>>
>>
>>
>> *From:* Mohammad Shamsi [mailto:m.h.shams@gmail.com]
>> *Sent:* Montag, 26. Mai 2008 08:50
>> *To:* users@glassfish.dev.java.net
>> *Subject:* Re: exception handling in EJB3 Stateless and JAX -WS. guide
>> tutorial example...
>>
>>
>>
>> Hi Markus,
>>
>> In Java EE 5 we can one code for both Session Bean and Web Service.
>>
>> @WebService
>> @Stateless
>> public class FooImpl implements Foo {
>> public void dofoo() {
>> }
>> }
>>
>> clients can call dofoo method, either via RMI (as a Session Bean) or
>> SOAP/HTTP (as a web method)
>>
>> for web service clients i can throw just a SOAPFaultException and for RMI
>> clients i can throw any exception.
>>
>> i have to know that how to handle and throw exception from this method
>> that both clients can use it.
>>
>>
>> On Mon, May 26, 2008 at 9:57 AM, Markus Karg <karg@quipsy.de> wrote:
>>
>> What exactly do you want to know?
>>
>>
>>
>> Regards
>>
>> Markus
>>
>>
>>
>> *From:* Mohammad Shamsi [mailto:m.h.shams@gmail.com]
>> *Sent:* Samstag, 24. Mai 2008 12:33
>> *To:* users@glassfish.dev.java.net
>> *Subject:* exception handling in EJB3 Stateless and JAX -WS. guide
>> tutorial example...
>>
>>
>>
>> hi all,
>>
>> im looking for guides and examples for Exception Handling in EJB3
>> Stateless Session Bean and JAX WS
>>
>> any resources ? idea ?
>>
>>
>>
>>
>> --
>> sincerely yours
>> M. H. Shamsi
>>
>>
>>
>>
>> --
>> sincerely yours
>> M. H. Shamsi
>>
>
>
>
> --
> sincerely yours
> M. H. Shamsi
>



--
sincerely yours
M. H. Shamsi
[att1.html]


Mohammad Shamsi
Re: exception handling in EJB3 Stateless and JAX -WS. guide tutorial example...
Posted: May 26, 2008 12:22 AM   in response to: Markus Karg
  Click to reply to this thread Reply

Hi Markus,

In Java EE 5 we can one code for both Session Bean and Web Service.

@WebService
@Stateless
public class FooImpl implements Foo {
public void dofoo() {
}
}

clients can call dofoo method, either via RMI (as a Session Bean) or
SOAP/HTTP (as a web method)

for web service clients i can throw just a SOAPFaultException and for RMI
clients i can throw any exception.

i have to know that how to handle and throw exception from this method that
both clients can use it.



On Mon, May 26, 2008 at 9:57 AM, Markus Karg <karg@quipsy.de> wrote:

> What exactly do you want to know?
>
>
>
> Regards
>
> Markus
>
>
>
> *From:* Mohammad Shamsi [mailto:m.h.shams@gmail.com]
> *Sent:* Samstag, 24. Mai 2008 12:33
> *To:* users@glassfish.dev.java.net
> *Subject:* exception handling in EJB3 Stateless and JAX -WS. guide
> tutorial example...
>
>
>
> hi all,
>
> im looking for guides and examples for Exception Handling in EJB3
> Stateless Session Bean and JAX WS
>
> any resources ? idea ?
>
>
>
>
> --
> sincerely yours
> M. H. Shamsi
>



--
sincerely yours
M. H. Shamsi
[att1.html]


dnlcy

Posts: 15
Re: exception handling in EJB3 Stateless and JAX -WS. guide tutorial exampl
Posted: Jun 21, 2008 11:08 AM   in response to: Mohammad Shamsi
  Click to reply to this thread Reply

Hi all,

I'm having a similar question. How the right way to throw an exception in web services?

My situation is explain here:
http://forum.java.sun.com/thread.jspa?threadID=5307322

dnlcy

Posts: 15
Re: exception handling in EJB3 Stateless and JAX -WS. guide tutorial exampl
Posted: Jun 23, 2008 4:04 AM   in response to: dnlcy
  Click to reply to this thread Reply

I solved my situation. Throwing my own exception. Only thing I couln'd do was to throw a SOAPFaultException or any RuntimeException.

The solution passed by defining explicitly an endpointInterface.

Code tested posted here:
http://forum.java.sun.com/thread.jspa?messageID=10307225




 XML java.net RSS