Troubleshooting "Unable to unmarshall exception response with the unmarshallers provided" in Java

2 minute read
Content level: Advanced
1

Troubleshooting Java SDK v1 with JDK 17

Introduction:

When working with the Java SDK v1 and JDK 17 or higher, you may encounter the exception Unable to unmarshall exception response with the unmarshallers provided. This error occurs due to a package mismatch between the SDK and the JDK. In this article, we will explore this issue in detail and provide steps to resolve it.

Understanding the Exception:

The AWS Java SDK version 1 (v1) supports Java versions from 7 to 16. The Java 17 version introduces strong encapsulation of internal Java elements, which is not backwards-compatible with the Java SDK v1. This may cause issues for certain use-cases of the SDK.

Solution:

To resolve the issue we highly recommend upgrading to Java SDK v2. which is the recommended version and is designed to be compatible with newer JDK versions while offering improved features and functionalities. Upgrading to Java SDK v2 ensures long-term support, compatibility with JDK 17 and future versions, and access to the latest advancements in Java. By making this upgrade, you can resolve the exception and future-proof your application against deprecation concerns.

If you are experiencing issues with Java 17+ and unable to migrate to AWS SDK for Java v2 at this time, below are the workarounds that you might find helpful. Please keep in mind that these workarounds may not work in the future versions of Java. See JEP 403: Strongly Encapsulate JDK Internals and Breaking Encapsulation for more details.

Error: com.amazonaws.AmazonServiceException: Unable to unmarshall exception response with the unmarshallers provided caused by java.lang. reflect.InaccessibleObjectException

use JVM option --add-opens java.base/java.lang=ALL-UNNAMED at JVM startup

WARNING: Illegal reflective access by com.amazonaws.util.XpathUtils

use JVM option --add-opens=java.xml/com.sun.org.apache.xpath.internal=ALL-UNNAMED at JVM startup

Conclusion:

The Unable to unmarshall exception response with the unmarshallers provided exception in AWS Java SDK v1 with JDK 17 or higher occurs due to a package mismatch between the SDK and JDK versions. Upgrading to the AWS Java SDK v2 can help resolve this issue. However, before making any changes, consider the backward compatibility and thoroughly test your application to ensure the proper functioning of AWS service operations.