seek-oss / gradle-aws-plugin

AWS Plugin for Gradle
MIT License
10 stars 5 forks source link

Java 11 - JAXB is unavailable. Will fallback to SDK implementation which may be less performant #15

Open silver-mx opened 5 years ago

silver-mx commented 5 years ago

When using the plugin with java 11 I can see the following message:

JAXB is unavailable. Will fallback to SDK implementation which may be less performant.

Googling a bit I found the following file from the AWS SDK:

https://github.com/aws/aws-sdk-java/blob/8542b3ddc6be843dc910b3ccb1e6aeb3cc05c001/aws-java-sdk-core/src/main/java/com/amazonaws/util/Base64.java

Which suggests including a dependency to javax.xml.bind:jaxb-api when using Java 9+. Any chance to fix this to make it more compatible with Java 9+?

NOTE: I tried adding the dependency in my build.grade but id did not have any effect apparently.

silver-mx commented 5 years ago

My bad a runtime dpendency to 'javax.xml.bind:jaxb-api:2.3.1' fixed the issue. Sorry!

silver-mx commented 5 years ago

I am still getting the error I am afraid. Do you have plan to add support for Java 11?

antgustech commented 4 years ago

This issue is still present as of May 2020.

mdrijwan commented 3 years ago

i'm still facing this issue as of January 2021!

silleruss commented 3 years ago

how about add dependency you can find that issue in this wiki

shaoyongyang commented 3 years ago

i'm still facing this issue as of September 2021!

aniket1418 commented 2 years ago

I am also facing the same issue in December 2021

Hooneats commented 2 years ago

i'm still facing this issue

ghost commented 2 years ago

Same issue

AWilson10 commented 2 years ago

I have the same issue. Message is: WARN [com.amazonaws.util.Base64] - JAXB is unavailable. Will fallback to SDK implementation which may be less performant.If you are using Java 9+, you will need to include javax.xml.bind:jaxb-api as a dependency.

I added this to my pom file but no difference:

javax.xml.bind jaxb-api 2.3.1
nikitasius commented 2 years ago

implementation("javax.xml.bind:jaxb-api:2.3.1") and still facing it.

schmidlop commented 2 years ago

apparently still an issue august 2022

stephmafole commented 2 years ago

In my very last project (August 2022), including JAXB as an implementation dependency solved the issue.

What if you guys give a bit more explanations regarding the logic you're implementing ? It may help definitely solve this issue.

Screenshot from 2022-09-10 07-20-31

ProLlamaRacer commented 2 years ago

Have the same issue on alpine using jdk-11. Using version 1.12.323 give the same error. Code that causes it: ` AmazonS3 s3Client = AmazonS3ClientBuilder.defaultClient(); TransferManager tm = TransferManagerBuilder.standard().withS3Client(s3Client).build(); PutObjectRequest request = new PutObjectRequest(bucket_name, key_name, new File(file_path));

        Upload upload = tm.upload(request);
        try {
            upload.waitForCompletion();`
guillaumeyan commented 1 year ago

I migrated to Spring boot 3 and I no longer have the dependency to javax but instead Jakarta. Is there an update that will solve this ?

KostadinP commented 1 year ago

Have the same issue on alpine using jdk-11. Using version 1.12.323 give the same error. Code that causes it: ` AmazonS3 s3Client = AmazonS3ClientBuilder.defaultClient(); TransferManager tm = TransferManagerBuilder.standard().withS3Client(s3Client).build(); PutObjectRequest request = new PutObjectRequest(bucket_name, key_name, new File(file_path));

        Upload upload = tm.upload(request);
        try {
            upload.waitForCompletion();`

@ProLlamaRacer I'm having the same issue, did you find a way around it?

martppa commented 12 months ago

Using latest version solves the issue: implementation 'com.amazonaws:aws-java-sdk-s3:1.12.429' implementation 'javax.xml.bind:jaxb-api:2.4.0-b180830.0359'

yk-littlepay commented 9 months ago

FYI I've written some test like below to compare the time, and here is the result with and without the recommended dependencies enabled, and I don't see any difference, moreover the standard java.util.Base64 works the fastest, 9 times (and quite noticeably)

package com.base64;

import lombok.val;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import java.io.IOException;
import java.util.Collection;
import java.util.LinkedList;
import java.util.Random;
import java.util.stream.Stream;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class Base64Test {
    private static final Collection<byte[]> DATA = data(2000, 165536);

    @Order(0)
    @Test
    void testData() {
        assert DATA.size() == 2000;
    }

    @Order(1)
    @ParameterizedTest
    @MethodSource("encoders")
    void testEncode(final Coder coder) {
        for (val data : DATA) {
            val encoded = coder.encode(data);
            assert encoded != null;
            val decoded = coder.decode(encoded);
            assert data.length == decoded.length;
        }
    }

    private static Collection<byte[]> data(final int count, final int size) {
        val result = new LinkedList<byte[]>();
        val random = new Random();
        for (int i = 0; i < count; i++) {
            val data = new byte[size];
            random.nextBytes(data);
            result.add(data);
        }
        return result;
    }

    private static Stream<Coder> encoders() {
        val jub64 = new Coder.JavaUtilBase64();
        val aws64 = new Coder.AwsBase64();
        val bob64 = new Coder.BouncycastleBase64();
        val jsB64 = new Coder.JbossBase64();
        return Stream.of(jub64, jub64, jub64, jub64, jub64, jub64, jub64, jub64,
                         aws64, aws64, aws64, aws64, aws64, aws64, aws64, aws64,
                         jsB64, jsB64, jsB64, jsB64, jsB64, jsB64, jsB64, jsB64,
                         bob64, bob64, bob64, bob64, bob64, bob64, bob64, bob64);
    }

    interface Coder {
        String encode(byte[] data);

        byte[] decode(String text);

        final class JavaUtilBase64 implements Coder {
            @Override
            public String encode(final byte[] data) {
                return java.util.Base64.getEncoder().encodeToString(data);
            }

            @Override
            public byte[] decode(final String text) {
                return java.util.Base64.getDecoder().decode(text);
            }

            @Override
            public String toString() {
                return java.util.Base64.class.getName();
            }
        }

        final class AwsBase64 implements Coder {
            @Override
            public String encode(final byte[] data) {
                return com.amazonaws.util.Base64.encodeAsString(data);
            }

            @Override
            public byte[] decode(final String text) {
                return com.amazonaws.util.Base64.decode(text);
            }

            @Override
            public String toString() {
                return com.amazonaws.util.Base64.class.getName();
            }
        }

        final class BouncycastleBase64 implements Coder {
            @Override
            public String encode(final byte[] data) {
                return org.bouncycastle.util.encoders.Base64.toBase64String(data);
            }

            @Override
            public byte[] decode(final String text) {
                return org.bouncycastle.util.encoders.Base64.decode(text);
            }

            @Override
            public String toString() {
                return org.bouncycastle.util.encoders.Base64.class.getName();
            }
        }

        final class JbossBase64 implements Coder {

            @Override
            public String encode(final byte[] data) {
                return org.jboss.resteasy.jose.jws.util.Base64.encodeBytes(data);
            }

            @Override
            public byte[] decode(final String text) {
                try {
                    return org.jboss.resteasy.jose.jws.util.Base64.decode(text);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            @Override
            public String toString() {
                return org.jboss.resteasy.jose.jws.util.Base64.class.getName();
            }
        }
    }
}
no_dependecies has_dependecies
iremnuy commented 3 months ago

Adding

implementation 'com.amazonaws:aws-java-sdk-s3:1.12.707' implementation 'javax.xml.bind:jaxb-api:2.4.0-b180830.0359'

Solved the issue as of 29 July 2024

nikitasius commented 3 months ago

i use javax.xml.bind:jaxb-api:latest.release & com.amazonaws:aws-java-sdk-s3:latest.release and not seen that for a while.