Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find or access default constructor for {}, make sure corresponding package is open to azure-core #1738

Closed
Danijal98 opened this issue Sep 1, 2023 · 2 comments

Comments

@Danijal98
Copy link

Context

  • OS and version used: macOS
  • Java runtime used: Java 17
  • SDK version used: iotHubDeviceClientVersion=2.2.0, azureStorageBlobVersion=12.22.3, azureCore=1.40.0
  • Project Working on a KMP project inside an android module

Description of the issue

While migrating from version 1.29.4 to 2.2.0, following the guide at FileUploadSimpleSample, an exception arises during the endpoint() method call of creating a BlobClient. The failure point is identified within the HttpHeaderName class in the fromString() function, particularly when the ExpandableStringEnum::getDefaultConstructor is invoked. The function seems to be unable to find or access the default constructor for a given class and suggests ensuring the relevant package is open to azure-core.

Code sample exhibiting the issue

val blobClient = BlobClientBuilder()
                .endpoint(sasUriResponse.blobUri.toString())
                .buildClient()

The exception occurs within:

private static <T> MethodHandle getDefaultConstructor(Class<T> clazz) {
    try {
        MethodHandles.Lookup lookup = ReflectionUtils.getLookupToUse(clazz);
        return lookup.findConstructor(clazz, methodType(void.class));
    } catch (NoSuchMethodException | IllegalAccessException e) {
        LOGGER.verbose("Can't find or access default constructor for {}, make sure corresponding package is open to azure-core", clazz.getName(), e);
    } catch (Exception e) {
        LOGGER.verbose("Failed to get lookup for {}", clazz.getName(), e);
    }

    return null;
}

Console log of the issue

LOGGER.verbose("Can't find or access default constructor for {}, make sure corresponding package is open to azure-core", clazz.getName(), e);
@Danijal98 Danijal98 added the bug label Sep 1, 2023
@github-actions github-actions bot added the IoTSDK label Sep 1, 2023
@timtay-microsoft
Copy link
Member

timtay-microsoft commented Sep 8, 2023

Since this issue happens when using the Azure Storage SDK, this question may be more appropriate to ask in the repo that owns the Azure Storage SDK. You can file an issue for it here. As far as this repo is concerned, we can update the sample code's dependency on the Azure Storage SDK if there is a version that fixes this issue for you.

@timtay-microsoft
Copy link
Member

Since this is more an issue with Azure Storage SDK than this SDK, I'll go ahead and close this thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants