Raymond Feng wrote:

Hi,

I just tried and it apparently works with IBM JDK and SUN JDK is not happy with it. But anyway, we now use the JAXB to serialize POJO into XML and vice versa. The POJOs have to follow JavaBean patterns as I described in the e-mail when I checked in the changes.

The difference between using the IBM and Sun JDKs seems to be caused by
the IBM JDK having a private no-argument contructor on StackTraceElement
whereas the Sun JDK doesn't have this no-argument constructor at all.
There's no indication in the Javadoc for StackTraceElement to say which
of these implementations is correct.  The no-argument constructor isn't
mentioned, which presumably means it could be missing or could be private.

Because the Throwable base class for all exceptions has a getStackTrace()
method returning a StackTraceElement[] array, and this method is part of
a getter/setter pair, JAXB serialization and deserialization of exceptions
should fail (according to the JAXB spec) because of the absence of a
public or protected no-argument constructor on StackTraceElement.
It appears that when the IBM JDK is used, the introspection code in JAXB
incorrectly picks up the private no-argument constructor on
StackTraceElement and therefore the error does not occur.

There is a more minor problem even when using the IBM JDK.  Although the
exception makes it through to the client successfully, the exception's
detail message from the server is not being marshalled on the wire because
of a property name conflict between a superclass and a subclass.  I have
been able to modify the business exception class to work around this
problem.  Unfortunately I don't have any workaround for the more serious
problem with the Sun JDK.

Now the question is how do we serialize the pure java exceptions (not generated from JAX-WS) into XML so that they can flow over SOAP. Maybe we have to create a speical databinding from exceptions and then have special transformers to deal with the Exception/XML transformations.

Looking at the JAX-WS and JAXB specifications, it turns out that JAX-WS
does not use the normal JAXB mapping for exceptions.  It defines its own
custom mapping that removes some properties from the exception class to
avoid attempting to serialize things that should not be serialized.
See section 3.7 for details.  We need to implement this JAX-WS exception
mapping in Tuscany.

I have opened TUSCANY-1939 for this problem.  I will investigate how to
create and add a custom mapping for exceptions in the databinding
framework.  If there is any documentation on this that I could look at,
I would appreciate a pointer.

  Simon

Thanks,
Raymond

----- Original Message ----- From: "Simon Nash" <[EMAIL PROTECTED]>
To: <tuscany-dev@ws.apache.org>
Sent: Monday, December 17, 2007 2:24 PM
Subject: JAXB databinding causing build failure in itest/exceptions-simple-ws


I'm seeing the failure below when attempting to build
itest/exceptions-simple-ws from the latest trunk.

From the message and stack trace, it looks like the Exception2Exception
transformer that was previously using a POJO-JavaBean serializer has been
changed to use a JAXB serializer, and this is throwing a JAXB exception
because the business exception object contains an object whose class
doesn't have a no-arg constructor (java.lang.StackTraceElement).

Does anyone know what has changed here and the reason why?

  Simon

Here's the error:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.example.ExampleTestCase
17-Dec-2007 21:40:27 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.10
17-Dec-2007 21:40:27 org.apache.catalina.startup.ContextConfig defaultWebConfig
INFO: No default web.xml
17-Dec-2007 21:40:27 org.apache.catalina.startup.DigesterFactory register
WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd
17-Dec-2007 21:40:27 org.apache.catalina.startup.DigesterFactory register
WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_
1.dtd
17-Dec-2007 21:40:27 org.apache.catalina.startup.DigesterFactory register
WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_
2.dtd
17-Dec-2007 21:40:27 org.apache.catalina.startup.DigesterFactory register
WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_
0.xsd
17-Dec-2007 21:40:27 org.apache.catalina.startup.DigesterFactory register
WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xs
d
17-Dec-2007 21:40:27 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8085
17-Dec-2007 21:40:27 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8085
17-Dec-2007 21:40:27 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM
apping
INFO: Added Servlet mapping: http://EUREKA:8085/axis2/services/ExampleService 17-Dec-2007 21:40:28 org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceInOutSy
ncMessageReceiver invokeBusinessLogic
SEVERE: org.apache.tuscany.sca.databinding.TransformationException: com.sun.xml. bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExcept
ions
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.getS
tackTrace()
                at java.lang.Throwable
                at java.lang.Exception
                at com.example.BusinessException

org.osoa.sca.ServiceRuntimeException: org.apache.tuscany.sca.databinding.Transfo rmationException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 cou
nts 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.getS
tackTrace()
                at java.lang.Throwable
                at java.lang.Exception
                at com.example.BusinessException

at org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker.invoke(Runt
imeWireInvoker.java:127)
at org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker.invoke(Runt
imeWireInvoker.java:89)
at org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker.invoke(Runt
imeWireInvoker.java:83)
at org.apache.tuscany.sca.core.assembly.RuntimeWireImpl.invoke(RuntimeWi
reImpl.java:127)
at org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceProvider.invokeTa
rget(Axis2ServiceProvider.java:572)
at org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceInOutSyncMessageR
eceiver.invokeBusinessLogic(Axis2ServiceInOutSyncMessageReceiver.java:59)
at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBus
inessLogic(AbstractInOutSyncMessageReceiver.java:42)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMe
ssageReceiver.java:96)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:145) at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostReq
uest(HTTPTransportUtils.java:275)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:1
20)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:228)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:216)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ss(Http11Protocol.java:634)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoin
t.java:352)
at org.apache.tuscany.sca.core.work.Jsr237Work.run(Jsr237Work.java:61) at org.apache.tuscany.sca.core.work.ThreadPoolWorkManager$DecoratingWork
.run(ThreadPoolWorkManager.java:205)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:650)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:675)
        at java.lang.Thread.run(Thread.java:595)
Caused by: org.apache.tuscany.sca.databinding.TransformationException: com.sun.x ml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExc
eptions
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.getS
tackTrace()
                at java.lang.Throwable
                at java.lang.Exception
                at com.example.BusinessException

at org.apache.tuscany.sca.databinding.jaxb.JAXB2Node.transform(JAXB2Node
.java:49)
at org.apache.tuscany.sca.databinding.jaxb.JAXB2Node.transform(JAXB2Node
.java:33)
at org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint$L
azyPullTransformer.transform(DefaultTransformerExtensionPoint.java:199)
at org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(Mediator
Impl.java:73)
at org.apache.tuscany.sca.core.databinding.transformers.Exception2Except
ionTransformer.transform(Exception2ExceptionTransformer.java:98)
at org.apache.tuscany.sca.core.databinding.transformers.Exception2Except
ionTransformer.transform(Exception2ExceptionTransformer.java:35)
at org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(Mediator
Impl.java:73)
at org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterc
eptor.transformException(DataTransformationInterceptor.java:250)
at org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterc
eptor.invoke(DataTransformationInterceptor.java:148)
at org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker.invoke(Runt
imeWireInvoker.java:118)
        ... 28 more
Caused by: 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.getS
tackTrace()
                at java.lang.Throwable
                at java.lang.Exception
                at com.example.BusinessException

at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check
(IllegalAnnotationsException.java:102)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContex
tImpl.java:438)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.ja
va:286)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:
139)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:
117)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:211)
        at javax.xml.bind.ContextFinder.find(ContextFinder.java:372)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
at org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper.createJAXBC
ontext(JAXBContextHelper.java:59)
at org.apache.tuscany.sca.databinding.jaxb.JAXB2Node.transform(JAXB2Node
.java:40)
        ... 37 more
17-Dec-2007 21:40:28 org.apache.catalina.core.StandardWrapper unload
INFO: Waiting for 1 instance(s) to be deallocated
17-Dec-2007 21:40:28 org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8085
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 4.757 sec <<< FA
ILURE!
test(com.example.ExampleTestCase)  Time elapsed: 4.716 sec  <<< ERROR!
java.lang.reflect.UndeclaredThrowableException
        at $Proxy8.hello(Unknown Source)
at com.example.ExampleClientImpl.runTest(ExampleClientImpl.java:38)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tuscany.sca.implementation.java.invocation.JavaImplementat
ionInvoker.invoke(JavaImplementationInvoker.java:105)
at org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JD
KInvocationHandler.java:249)
at org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JD
KInvocationHandler.java:146)
        at $Proxy7.runTest(Unknown Source)
        at com.example.ExampleTestCase.test(ExampleTestCase.java:42)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at junit.framework.TestCase.runTest(TestCase.java:168)
        at junit.framework.TestCase.runBare(TestCase.java:134)
        at junit.framework.TestResult$1.protect(TestResult.java:110)
        at junit.framework.TestResult.runProtected(TestResult.java:128)
        at junit.framework.TestResult.run(TestResult.java:113)
        at junit.framework.TestCase.run(TestCase.java:124)
        at junit.framework.TestSuite.runTest(TestSuite.java:232)
        at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.
java:35)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.
java:62)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTes
tSet(AbstractDirectoryTestSuite.java:138)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(Ab
stractDirectoryTestSuite.java:125)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(Su
refireBooter.java:308)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.j
ava:879)
Caused by: org.apache.tuscany.sca.interfacedef.util.FaultException: org.apache.t uscany.sca.databinding.TransformationException: com.sun.xml.bind.v2.runtime.Ille
galAnnotationsException: 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.getS
tackTrace()
                at java.lang.Throwable
                at java.lang.Exception
                at com.example.BusinessException

at org.apache.tuscany.sca.binding.ws.axis2.Axis2BindingInvoker.invoke(Ax
is2BindingInvoker.java:79)
at org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterc
eptor.invoke(DataTransformationInterceptor.java:74)
at org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JD
KInvocationHandler.java:249)
at org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JD
KInvocationHandler.java:146)
        ... 34 more


Results :

Tests in error:
  test(com.example.ExampleTestCase)

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to