oracle / oci-java-sdk

Oracle Cloud Infrastructure SDK for Java
https://cloud.oracle.com/cloud-infrastructure
Other
192 stars 152 forks source link

Could not initialize class com.oracle.bmc.http.internal.RestClientFactory #572

Closed JoaoSchutz closed 3 months ago

JoaoSchutz commented 5 months ago

Hello. I'm implementing oci-java-sdk-objectstorage in my project and when I try to initialize the client, it always returns this: "Could not initialize class com.oracle.bmc.http.internal.RestClientFactory". I'm using Spring Boot and Java 8. I tried to find a solution on the internet but apparently I'm the lucky one hehe. Can you help me? Here is the code:

package example.code.services;

import java.io.IOException;
import org.springframework.context.annotation.Configuration;
import com.oracle.bmc.ConfigFileReader;
import com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider;
import com.oracle.bmc.objectstorage.ObjectStorage;
import com.oracle.bmc.objectstorage.ObjectStorageClient;

@Configuration
public class OracleClientConfiguration {

    String configurationFilePath = "src/main/resources/config/config";
    String profile = "DEFAULT";

    public ObjectStorage getObjectStorage() throws IOException{

        final ConfigFileReader.ConfigFile
                configFile = ConfigFileReader
                .parse(configurationFilePath, profile);

        final ConfigFileAuthenticationDetailsProvider provider =
                new ConfigFileAuthenticationDetailsProvider(configFile);

        return ObjectStorageClient.builder()
                .build(provider);
    }

}