diff --git a/test/hotspot/jtreg/compiler/aot/AotCompiler.java b/test/hotspot/jtreg/compiler/aot/AotCompiler.java
index 4ec32f2dc53..144665051c0 100644
--- a/test/hotspot/jtreg/compiler/aot/AotCompiler.java
+++ b/test/hotspot/jtreg/compiler/aot/AotCompiler.java
@@ -268,6 +268,7 @@ public class AotCompiler {
             }
         } catch (ArtifactResolverException e) {
             System.err.println("artifact resolution error: " + e);
+            e.printStackTrace(System.err);
             // let jaotc try to find linker
             return null;
         }
diff --git a/test/jdk/sun/security/pkcs11/PKCS11Test.java b/test/jdk/sun/security/pkcs11/PKCS11Test.java
index 9a38fff1ee3..892e598fab2 100644
--- a/test/jdk/sun/security/pkcs11/PKCS11Test.java
+++ b/test/jdk/sun/security/pkcs11/PKCS11Test.java
@@ -853,7 +853,7 @@ public abstract class PKCS11Test {
                         + "please check if JIB jar is present in classpath.");
             } else {
                 throw new RuntimeException("Fetch artifact failed: " + clazz
-                        + "\nPlease make sure the artifact is available.");
+                        + "\nPlease make sure the artifact is available.", e);
             }
         }
         Policy.setPolicy(null); // Clear the policy created by JIB if any
diff --git a/test/lib/jdk/test/lib/artifacts/ArtifactResolverException.java b/test/lib/jdk/test/lib/artifacts/ArtifactResolverException.java
index 28ba3096b36..17484d89d52 100644
--- a/test/lib/jdk/test/lib/artifacts/ArtifactResolverException.java
+++ b/test/lib/jdk/test/lib/artifacts/ArtifactResolverException.java
@@ -12,4 +12,16 @@ public class ArtifactResolverException extends Exception {
     public ArtifactResolverException(String message, Throwable cause) {
         super(message, cause);
     }
+
+    public String toString() {
+        return super.toString() + ": " + getRootCause().toString();
+    }
+
+    public Throwable getRootCause() {
+        Throwable rootCause = getCause();
+        while (rootCause.getCause() != null && rootCause.getCause() != rootCause) {
+            rootCause = rootCause.getCause();
+        }
+        return rootCause;
+    }
 }