[SMX4-330]JAXB 2.1 API - TypeConstraintException do not behave as expected by the spec

git-svn-id: https://svn.apache.org/repos/asf/servicemix/smx4/specs/trunk@801501 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/jaxb-api-2.1/src/main/java/javax/xml/bind/TypeConstraintException.java b/jaxb-api-2.1/src/main/java/javax/xml/bind/TypeConstraintException.java
index 8713b4b..25aa4b8 100644
--- a/jaxb-api-2.1/src/main/java/javax/xml/bind/TypeConstraintException.java
+++ b/jaxb-api-2.1/src/main/java/javax/xml/bind/TypeConstraintException.java
@@ -50,7 +50,8 @@
     }
 
     public Throwable getLinkedException() {
-        return getCause();
+        // Do not use getCause() as the cause was never initialized in the constructor
+        return linkedException;
     }
 
     public synchronized void setLinkedException(Throwable linkedException) {
@@ -64,11 +65,15 @@
     }
 
     public void printStackTrace() {
-        super.printStackTrace();
+        printStackTrace(System.err);
     }
 
     public void printStackTrace(PrintStream ps) {
+        if (this.linkedException != null) {
+            this.linkedException.printStackTrace(ps);
+            ps.println("--------------- linked to ------------------");
+        }
         super.printStackTrace(ps);
     }
 
-}
\ No newline at end of file
+}