You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by "Millies, Sebastian" <Se...@ids-scheer.com> on 2010/09/14 00:25:10 UTC
Throwable as method argument causes exception
As soon as I add an argument of type java.lang.Throwable to one of
my service methods, I get an error upon activation:
WARNUNG: Exception while generating WSDL for CurrencyConverter/CurrencyConverter
14.09.2010 00:11:23 org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator
SCHWERWIEGEND: Exception thrown was: org.osoa.sca.ServiceRuntimeException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
java.lang.StackTraceElement does not have a no-arg default constructor.
this problem is related to the following location:
at java.lang.StackTraceElement
at public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()
at java.lang.ThrowableThis
This is really bad. Where is this documented? Does every nested property of every method
argument have to have a no-arg constructor?
This makes the implementation of an SCA LogService in Tuscany 1.6 practically impossible, if
one cannot even pass in an exception object.
-- Sebastian
Re: Throwable as method argument causes exception
Posted by Mike Edwards <mi...@gmail.com>.
Millies, Sebastian wrote:
> but that should not be a problem here. I am not throwing an exception,
>
> I am simply passing one as a method parameter. -- Sebastian
>
Sebastian,
Ah yes, I ran into this entertaining problem when I coded the Async invocation code in 2.x.
Fundamentally, the problem is caused because Throwable is not serializable - as others have noted,
it has a getStackTrace() method which causes the problem.
When I wanted to pass an exception as a parameter, what I did was to create a wrapper class and put
the exception into the wrapper class, with the wrapper class taking care of the serialization of the
exception. This did mean that I did NOT serialize the stack trace - but in an SOA world, I think
that handing over stack traces between clients and services is not a good plan anyway, so I think
that this is OK.
You may wish to approach the problem along similar lines.
Yours, Mike.
Re: Throwable as method argument causes exception
Posted by Simon Nash <na...@apache.org>.
Millies, Sebastian wrote:
> but that should not be a problem here. I am not throwing an exception,
>
> I am simply passing one as a method parameter. -- Sebastian
>
All parameters need to follow the JAXB rules. One of these rules is
that any class mapped to JAXB must have a no-argument constructor.
The Throwable class has a getStackTrace() method that returns a
StackTraceElement[] array, and StackTraceElement doesn't have a
no-argument contructor.
To solve this problem you can use @XmlJavaTypeAdapter to marshal the
Throwable class (or any subclass of Throwable) using some other class
that conforms to the JAXB rules. I haven't had time yet to find out
why @XmlJavaTypeAdapter isn't working in Tuscany 1.6.
Simon
>
>
> *From:* Raymond Feng [mailto:enjoyjava@gmail.com]
> *Sent:* Tuesday, September 14, 2010 12:32 AM
> *To:* user@tuscany.apache.org
> *Subject:* Re: Throwable as method argument causes exception
>
>
>
> For remotable interfaces, SCA uses JAX-WS conventions to generate the
> WSDL from Java. And JAX-WS requires the (business, checked) exception to
> be mappable into a "fault" bean.
>
>
>
> Thanks,
>
> Raymond
>
> ________________________________________________________________
>
> Raymond Feng
>
> rfeng@apache.org <ma...@apache.org>
> /Apache Tuscany PMC member and committer: tuscany.apache.org
> Co-author of Tuscany SCA In Action book: www.tuscanyinaction.com
> Personal Web Site: www.enjoyjava.com/
>
> ________________________________________________________________
>
>
>
> On Sep 13, 2010, at 3:25 PM, Millies, Sebastian wrote:
>
>
>
> As soon as I add an argument of type java.lang.Throwable to one of
> my service methods, I get an error upon activation:
>
> WARNUNG: Exception while generating WSDL for
> CurrencyConverter/CurrencyConverter
> 14.09.2010 00:11:23
> org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator
> SCHWERWIEGEND: Exception thrown was:
> org.osoa.sca.ServiceRuntimeException:
> com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of
> IllegalAnnotationExceptions
> java.lang.StackTraceElement does not have a no-arg default constructor.
> this problem is related to the following location:
> at java.lang.StackTraceElement
> at public java.lang.StackTraceElement[]
> java.lang.Throwable.getStackTrace()
> at java.lang.ThrowableThis
>
> This is really bad. Where is this documented? Does every nested property
> of every method
> argument have to have a no-arg constructor?
>
> This makes the implementation of an SCA LogService in Tuscany 1.6
> practically impossible, if
> one cannot even pass in an exception object.
>
> -- Sebastian
>
>
>
RE: Throwable as method argument causes exception
Posted by "Millies, Sebastian" <Se...@ids-scheer.com>.
but that should not be a problem here. I am not throwing an exception,
I am simply passing one as a method parameter. -- Sebastian
From: Raymond Feng [mailto:enjoyjava@gmail.com]
Sent: Tuesday, September 14, 2010 12:32 AM
To: user@tuscany.apache.org
Subject: Re: Throwable as method argument causes exception
For remotable interfaces, SCA uses JAX-WS conventions to generate the WSDL from Java. And JAX-WS requires the (business, checked) exception to be mappable into a "fault" bean.
Thanks,
Raymond
________________________________________________________________
Raymond Feng
rfeng@apache.org
Apache Tuscany PMC member and committer: tuscany.apache.org
Co-author of Tuscany SCA In Action book: www.tuscanyinaction.com
Personal Web Site: www.enjoyjava.com
________________________________________________________________
On Sep 13, 2010, at 3:25 PM, Millies, Sebastian wrote:
As soon as I add an argument of type java.lang.Throwable to one of
my service methods, I get an error upon activation:
WARNUNG: Exception while generating WSDL for CurrencyConverter/CurrencyConverter
14.09.2010 00:11:23 org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator
SCHWERWIEGEND: Exception thrown was: org.osoa.sca.ServiceRuntimeException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
java.lang.StackTraceElement does not have a no-arg default constructor.
this problem is related to the following location:
at java.lang.StackTraceElement
at public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()
at java.lang.ThrowableThis
This is really bad. Where is this documented? Does every nested property of every method
argument have to have a no-arg constructor?
This makes the implementation of an SCA LogService in Tuscany 1.6 practically impossible, if
one cannot even pass in an exception object.
-- Sebastian
Re: Throwable as method argument causes exception
Posted by Raymond Feng <en...@gmail.com>.
For remotable interfaces, SCA uses JAX-WS conventions to generate the WSDL from Java. And JAX-WS requires the (business, checked) exception to be mappable into a "fault" bean.
Thanks,
Raymond
________________________________________________________________
Raymond Feng
rfeng@apache.org
Apache Tuscany PMC member and committer: tuscany.apache.org
Co-author of Tuscany SCA In Action book: www.tuscanyinaction.com
Personal Web Site: www.enjoyjava.com
________________________________________________________________
On Sep 13, 2010, at 3:25 PM, Millies, Sebastian wrote:
> As soon as I add an argument of type java.lang.Throwable to one of
> my service methods, I get an error upon activation:
>
> WARNUNG: Exception while generating WSDL for CurrencyConverter/CurrencyConverter
> 14.09.2010 00:11:23 org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator
> SCHWERWIEGEND: Exception thrown was: org.osoa.sca.ServiceRuntimeException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
> java.lang.StackTraceElement does not have a no-arg default constructor.
> this problem is related to the following location:
> at java.lang.StackTraceElement
> at public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()
> at java.lang.ThrowableThis
>
> This is really bad. Where is this documented? Does every nested property of every method
> argument have to have a no-arg constructor?
>
> This makes the implementation of an SCA LogService in Tuscany 1.6 practically impossible, if
> one cannot even pass in an exception object.
>
> -- Sebastian