You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS S3创建Bucket遇java.lang.NoSuchFieldError: JAVA_VENDOR问题

Fixing NoSuchFieldError: JAVA_VENDOR When Creating S3 Bucket with AWS SDK for Java

Let me share how I resolved this frustrating error when working with the AWS SDK for Java to create an S3 bucket.

The Error I Encountered

When running my code, I hit this exact error:

Exception in thread "main" java.lang.NoSuchFieldError: JAVA_VENDOR

The stack trace pointed directly to methods in software.amazon.awssdk.core.internal.util.UserAgentUtils.

My Environment

  • Java: OpenJDK 11 (version 11.0.1)
  • Build Tool: Apache Maven 3.5.4

What I Tried First

I initially suspected a missing system property, so I added this line to my code to manually set the vendor value:

System.setProperty("JAVA_VENDOR","Oracle Corporation");

This didn't fix the problem. Digging into the SDK code, I realized the real issue: UserAgentUtils was trying to reference a JAVA_VENDOR field that doesn't exist in software.amazon.awssdk.utils.JavaSystemSettings.

The Actual Fix

The root cause was an outdated AWS SDK version. Here's what I updated in my Maven POM file to resolve it:

1. Update the AWS SDK BOM Version

In the dependencyManagement section, I upgraded the BOM version from 2.0.0 to 2.5.19:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>bom</artifactId>
            <version>2.5.19</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

2. Add the sdk-core Dependency

I also explicitly added the sdk-core dependency to ensure all required core SDK classes are properly included:

<dependencies>
    <dependency>
        <groupId>software.amazon.awssdk</groupId>
        <artifactId>sdk-core</artifactId>
    </dependency>
    <!-- Include your other AWS SDK dependencies (like s3) here -->
</dependencies>

After making these changes, the error vanished entirely, and I could successfully create the S3 bucket as intended.

内容的提问来源于stack exchange,提问作者NyansusCoder

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 04:39:16