All Products
Search
Document Center

Object Storage Service:FAQ about OSS SDK for Java

Last Updated:Dec 17, 2024

This topic describes the causes of and solutions to common errors that may occur when you use Object Storage Service (OSS) SDK for Java.

JAR package conflicts

  • Cause

    If the response is similar to one of the following responses, your project has a package conflict.

    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/ssl/TrustStrategy
        at com.aliyun.oss.OSSClient.<init>(OSSClient.java:268)
        at com.aliyun.oss.OSSClient.<init>(OSSClient.java:193)
        at com.aliyun.oss.demo.HelloOSS.main(HelloOSS.java:77)
    Caused by: java.lang.ClassNotFoundException: org.apache.http.ssl.TrustStrategy
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        ... 3 more
                        

    Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE
     at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:52)
     at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:56)
     at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<clinit>(DefaultHttpRequestWriterFactory.java:46)
     at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<init>(ManagedHttpClientConnectionFactory.java:82)
     at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<init>(ManagedHttpClientConnectionFactory.java:95)
     at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<init>(ManagedHttpClientConnectionFactory.java:104)
     at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<clinit>(ManagedHttpClientConnectionFactory.java:62)
     at org.apache.http.impl.conn.PoolingHttpClientConnectionManager$InternalConnectionFactory.<init>(PoolingHttpClientConnectionManager.java:572)
     at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:174)
     at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:158)
     at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:149)
     at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:125)
     at com.aliyun.oss.common.comm.DefaultServiceClient.createHttpClientConnectionManager(DefaultServiceClient.java:237)
     at com.aliyun.oss.common.comm.DefaultServiceClient.<init>(DefaultServiceClient.java:78)
     at com.aliyun.oss.OSSClient.<init>(OSSClient.java:268)
     at com.aliyun.oss.OSSClient.<init>(OSSClient.java:193)
     at OSSManagerImpl.upload(OSSManagerImpl.java:42)
     at OSSManagerImpl.main(OSSManagerImpl.java:63)
                        

    OSS SDK for Java uses Apache HttpClient 4.4.1, whereas your project uses the Apache HttpClient or Commons HttpClient JAR package that conflicts with Apache HttpClient 4.4.1. To view the JAR package and the version that is used in your project, run the mvn dependency: tree command in the directory of the project. The following figure shows that your project uses Apache HttpClient 4.3.

  • Solution

    You can use one of the following methods to resolve the JAR package conflict:

    • Use the same version of Apache HttpClient. If your project uses a version that conflicts with Apache HttpClient 4.4.1, use Apache HttpClient 4.4.1 and delete dependencies for other versions from the pom.xml file. If your project uses Commons HttpClient, conflicts may also occur. To resolve these conflicts, delete Commons HttpClient.

    • Resolve dependency conflicts. If your project has multiple dependent third-party packages and the third-party packages depend on different versions of Apache HttpClient, dependency conflicts may occur in your project. You must exclude these dependencies. For more information, see Optional & Exclusion.

    OSS SDK for Java is dependent on the following package versions. The solution to conflicts is similar to that for HttpClient.

Missing packages

  • Cause

    If the response is similar to one of the following responses, your project may not have the packages required to compile or run OSS SDK for Java:

    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials
            at com.aliyun.oss.OSSClient.<init>(OSSClient.java:268)
            at com.aliyun.oss.OSSClient.<init>(OSSClient.java:193)
            at com.aliyun.oss.demo.HelloOSS.main(HelloOSS.java:76)
    Caused by: java.lang.ClassNotFoundException: org.apache.http.auth.Credentials
            at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
            ... 3 more
                        

    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/protocol/HttpContext
            at com.aliyun.oss.OSSClient.<init>(OSSClient.java:268)
            at com.aliyun.oss.OSSClient.<init>(OSSClient.java:193)
            at com.aliyun.oss.demo.HelloOSS.main(HelloOSS.java:76)
    Caused by: java.lang.ClassNotFoundException: org.apache.http.protocol.HttpContext
            at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
            ... 3 more
                        

    Exception in thread "main" java.lang.NoClassDefFoundError: org/jdom/input/SAXBuilder
            at com.aliyun.oss.internal.ResponseParsers.getXmlRootElement(ResponseParsers.java:645)
            at … … 
            at com.aliyun.oss.OSSClient.doesBucketExist(OSSClient.java:471)
            at com.aliyun.oss.OSSClient.doesBucketExist(OSSClient.java:465)
            at com.aliyun.oss.demo.HelloOSS.main(HelloOSS.java:82)
    Caused by: java.lang.ClassNotFoundException: org.jdom.input.SAXBuilder
            at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
            ... 11 more
                        

    OSS SDK for Java has the following dependencies:

    • aliyun-sdk-oss-2.2.1.jar

    • hamcrest-core-1.1.jar

    • jdom-1.1.jar

    • commons-codec-1.9.jar

    • httpclient-4.4.1.jar

    • commons-logging-1.2.jar

    • httpcore-4.4.1.jar

    • log4j-1.2.15.jar

    All packages except the log4j-1.2.15.jar package are required to compile or run OSS SDK for Java. However, if you want to enable logging, you must also include the log4j-1.2.15.jar package.

  • Solution

    You can use one of the following methods to add OSS SDK for Java dependencies to your project:

    • If your project is in Eclipse, import dependencies to Eclipse. For more information, see Installation.

    • If your project is in Ant, add OSS SDK for Java dependencies to the lib directory.

    • If you use the .javac or .java file, use the -classpath or -cp command to specify the path to the dependencies of OSS SDK for Java, or place the dependencies in the classpath path.

Connection timeout

  • Cause

    If the response is similar to the following one, connection timeout errors may occur due to invalid endpoints or unavailable networks:

    com.aliyun.oss.ClientException: SocketException
        at com.aliyun.oss.common.utils.ExceptionFactory.createNetworkException(ExceptionFactory.java:71)
        at com.aliyun.oss.common.comm.DefaultServiceClient.sendRequestCore(DefaultServiceClient.java:116)
        at com.aliyun.oss.common.comm.ServiceClient.sendRequestImpl(ServiceClient.java:121)
        at com.aliyun.oss.common.comm.ServiceClient.sendRequest(ServiceClient.java:67)
        at com.aliyun.oss.internal.OSSOperation.send(OSSOperation.java:92)
        at com.aliyun.oss.internal.OSSOperation.doOperation(OSSOperation.java:140)
        at com.aliyun.oss.internal.OSSOperation.doOperation(OSSOperation.java:111)
        at com.aliyun.oss.internal.OSSBucketOperation.getBucketInfo(OSSBucketOperation.java:1152)
        at com.aliyun.oss.OSSClient.getBucketInfo(OSSClient.java:1220)
        at com.aliyun.oss.OSSClient.getBucketInfo(OSSClient.java:1214)
        at com.aliyun.oss.demo.HelloOSS.main(HelloOSS.java:94)
    Caused by: org.apache.http.conn.HttpHostConnectException: Connect to oss-test.oss-cn-hangzhou-internal.aliyuncs.com:80 [oss-test.oss-cn-hangzhou-internal.aliyuncs.com/10.84.135.99] failed: Connection timed out: connect
        at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:151)
        at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
        at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
        at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
        at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
        at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
        at com.aliyun.oss.common.comm.DefaultServiceClient.sendRequestCore(DefaultServiceClient.java:113)
        ... 9 more
                        
  • Solution

    Use ossutil to troubleshoot the issue.

What do I do if the "SignatureDoesNotMatch" error message is returned?

  • Cause 1

    The AccessKey secret does not match the AccessKey ID.

    For more information about how to obtain the AccessKey ID and AccessKey secret, see Obtain an AccessKey pair.

  • Cause 2

    The signed URL is incorrectly used. The following sample code provides an example of how a signed URL is incorrectly used:

    GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucketName, object);
    request.setExpiration( new Date(new Date().getTime() + 3600 * 1000));
    request.addUserMetadata("author");
    URL url = ossClient.generatePresignedUrl(request);
    
    Map<String, String> header = new HashMap<String, String>();
    header.put("author");
    ossClient.putObject(url, new ByteArrayInputStream("Hello OSS".getBytes()), -1, header);

    If the Method parameter is not specified, the signed URL is generated to initiate a GET request. In the preceding example, the error is returned because the signed URL is used to initiate a PutObject request. In this case, you must set the Method parameter to PUT.

    In addition, the user metadata headers in a PutObject request must start with the x-oss-meta- prefix. In the preceding example, the user metadata field must be changed to x-oss-meta-author.

    Solution:

    Specify the correct method and modify the header. The following sample code provides an example on how to specify the Method parameter and modify the header in the request:

    request.addUserMetadata("author");
    request.setMethod(HttpMethod.PUT);
    URL url = ossClient.generatePresignedUrl(request);
    
    Map<String, String> header = new HashMap<String, String>();
    header.put("x-oss-meta-" + "author");
    ossClient.putObject(url, new ByteArrayInputStream("Hello OSS".getBytes()), -1, header);
  • Cause 3

    • The version of OSS SDK for Java that you use is earlier than 3.7.0 and HttpClient 4.5.9 or later is used in your project.

    • The name of the uploaded object contains the + character, which is not URL-encoded by HttpClient 4.5.9 and causes an signature inconsistency between the client and server.

    1

    Solution:

    • Upgrade your OSS SDK for Java to version 3.11.1 or later to ensure compatibility with HttpClient 4.5.9.

    • Remove unnecessary HttpClient dependencies. OSS SDK for Java automatically imports HttpClient. If HttpClient is imported by a third-party library, use solutions in JAR package conflicts to resolve conflicts.

  • Cause 4

    HttpClient 4.5.10 or later is imported to your project, and the request headers contain characters that are not supported by ISO/9959-1. For example, the headers whose names start with x-oss-meta- contain Chinese characters.3

    Solution

    • Remove the conflicting HttpClient versions. For more information, see JAR package conflicts.

    • Make sure that the characters contained in the request headers are supported by ISO/9959-1.

What do I do if the "Failed to parse the response result" error message is returned?

FAQ3

  • Cause

    HTTP requests are intercepted by the software deployed on the client or hijacked by a router on the Internet.

    Java 11 is installed but the dependencies on JAXB are not added to the pom.xml file.

  • Solution

    Initiate requests by using HTTPS.

    Add required JAXB dependencies to the pom.xml file. For more information, see Installation.

org.apache.http.NoHttpResponseException: The target server failed to respond

  • Cause

    A similar output is displayed when you run OSS SDK for Java:

    The preceding error may occur if expired connections are used. This error occurs only if an OSS SDK for Java version earlier than 2.1.2 is used.

  • Solution

    Upgrade OSS SDK for Java to 2.1.2 or later.

What do I do if JVM contains a large number of org.apache.http.impl.conn.PoolingHttpClientConnectionManager instances?

  • Cause

    The OSSClient instances are not shut down.

  • Solution

    Shut down the OSSClient instances that are executed or use the single instance mode.

What do I do if OSS SDK for Java stops responding?

  • Cause

    OSS SDK for Java stops responding when OSS SDK for Java is called. Run the jstack -l pid command to view the stack.

    "main" prio=6 tid=0x000000000291e000 nid=0xc40 waiting on condition [0x0000000002dae000]
    java.lang.Thread.State: WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x00000007d85697f8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
        at org.apache.http.pool.PoolEntryFuture.await(PoolEntryFuture.java:138)
        at org.apache.http.pool.AbstractConnPool.getPoolEntryBlocking(AbstractConnPool.java:306)
        at org.apache.http.pool.AbstractConnPool.access$000(AbstractConnPool.java:64)
        at org.apache.http.pool.AbstractConnPool$2.getPoolEntry(AbstractConnPool.java:192)
        at org.apache.http.pool.AbstractConnPool$2.getPoolEntry(AbstractConnPool.java:185)
        at org.apache.http.pool.PoolEntryFuture.get(PoolEntryFuture.java:107)
        at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.leaseConnection(PoolingHttpClientConnectionManager.java:276)
        at org.apache.http.impl.conn.PoolingHttpClientConnectionManager$1.get(PoolingHttpClientConnectionManager.java:263)
        at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:190)
        at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
        at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
        at com.aliyun.oss.common.comm.DefaultServiceClient.sendRequestCore(DefaultServiceClient.java:113)
        at com.aliyun.oss.common.comm.ServiceClient.sendRequestImpl(ServiceClient.java:123)
        at com.aliyun.oss.common.comm.ServiceClient.sendRequest(ServiceClient.java:68)
        at com.aliyun.oss.internal.OSSOperation.send(OSSOperation.java:94)
        at com.aliyun.oss.internal.OSSOperation.doOperation(OSSOperation.java:146)
        at com.aliyun.oss.internal.OSSOperation.doOperation(OSSOperation.java:113)
        at com.aliyun.oss.internal.OSSObjectOperation.getObject(OSSObjectOperation.java:229)
        at com.aliyun.oss.OSSClient.getObject(OSSClient.java:629)
        at com.aliyun.oss.OSSClient.getObject(OSSClient.java:617)
        at samples.HelloOSS.main(HelloOSS.java:49)
                        

    The error is caused by connection leaks in the connection pool. These leaks may occur if ossObject is not shut down after usage.

  • Solution

    Check your program to ensure that no connection leaks occur. The following sample code provides an example on how to shut down ossObject:

    // Read the object.
    OSSObject ossObject = ossClient.getObject(bucketName, objectName);
    // Perform operations on OSS.
    // Shut down ossObject.
    ossObject.close();
                        

Connection closure

  • Cause

    A response similar to the following one is returned when you use ossClient.getObject:

    Exception in thread "main" org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited message body (expected: 11990526; received: 202880)
        at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:180)
        at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:200)
        at org.apache.http.impl.io.ContentLengthInputStream.close(ContentLengthInputStream.java:103)
        at org.apache.http.impl.execchain.ResponseEntityProxy.streamClosed(ResponseEntityProxy.java:128)
        at org.apache.http.conn.EofSensorInputStream.checkClose(EofSensorInputStream.java:228)
        at org.apache.http.conn.EofSensorInputStream.close(EofSensorInputStream.java:174)
        at java.io.FilterInputStream.close(FilterInputStream.java:181)
        at java.io.FilterInputStream.close(FilterInputStream.java:181)
        at com.aliyun.oss.event.ProgressInputStream.close(ProgressInputStream.java:147)
        at java.io.FilterInputStream.close(FilterInputStream.java:181)
        at samples.HelloOSS.main(HelloOSS.java:39)
                        

    The error occurs because the interval between the two data reading attempts exceeds 1 minute. OSS closes the connection if no data is sent or received for more than 1 minute.

  • Solution

    If you must read part of the data during unspecified time periods, we recommend that you use range download to prevent disconnection during data reading. When the range download task is complete, the connection is closed. For more information, see Range download.

Memory leaks

  • Cause

    Memory leaks occur when OSS SDK for Java runs for an extended period of time. This period can range from a few hours to several days based on the amount of access traffic. We recommend that you use the Eclipse Memory Analyzer (MAT) to analyze memory usage. For more information, see Use MAT for Heap Dump Analysis.

    If a similar analysis result is displayed, PoolingHttpClientConnectionManager consumes 96% of memory. The possible cause is that the new OSSClient command is run multiple times and ossClient.shutdown is not called. As a result, memory leaks occur.

  • Solution

    Make sure that ossClient.shutdown is called after the new OSSClient command is run.

What do I do if the "InterruptedException" error occurs when ossClient.shutdown is called?

  • Cause

    A similar error is displayed when ossClient.shutdown is called by using OSS SDK for Java earlier than V2.3.0:

    java.lang.InterruptedException: sleep interrupted
            at java.lang.Thread.sleep(Native Method)
            at com.aliyun.oss.common.comm.IdleConnectionReaper.run(IdleConnectionReaper:76)
                        

    The error occurs because the backend thread (IdleConnectionReaper) of ossClient closes idle connections periodically. If ossClient.shutdown is called when IdleConnectionReaper is in Sleep mode, the preceding error occurs.

  • Solution

    Use the following code to ignore the error:

    try {
        ossClient.shutdown();
    } catch(Exception e) {
    }
                        

What do I do if the "SDK.ServerUnreachable: Specified endpoint or uri is not valid" error message is returned?

  • Cause

    • Requests are sent from the client to Security Token Service (STS) with high concurrency.

    • Connections to the server time out.

    • STS SDK and the SDK core are not the latest versions.

  • Solution

    • When Elastic Compute Service (ECS) instances on the client or on-premises computer are unable to support bursts of requests, reduce the number of concurrent requests sent to STS.

    • If the connection to the server times out, check and analyze the captured packets.

    • We recommend that you upgrade STS SDK or the SDK core to the latest version.

NoSuchKey

  • Cause

    The error message returned because the required object does not exist.

  • Solution

    For information about how to resolve this issue, see HTTP status code 404.

SocketException

  • Cause

    The error occurs because the socket failed to be specified during initialization. As a result, the request was not received by OSS.

  • Solution

    We recommend that you troubleshoot the error from the following aspects:

    • Check whether jitters occur.

    • Check whether socket resources are exhausted by other processes.

    • Check the maximum number of connections configured in OSS SDK for Java. If the actual number of connections exceeds the connection limit, a socket exception occurs.

    If the error persists, we recommend that you use tcpdump or Wireshark to capture packets, reproduce the error, and analyze the packets.

What do I do if the callback operation of OSS PostObject fails?

The callback operation of OSS PostObject fails but the callback operation of PutObject is succeedful. In most cases, if the JSON format is invalid or a callback fails, an error message is returned. In this case, you must test whether the callback operations of PUT and POST are triggered.

  • Cause

    The callback parameter follows the file parameter when you send the request.

  • Solution

    Change the position of the callback parameter.

    The test results show that the server captures the request.

Connection pool shut down

Caused by: java.lang.IllegalStateException: Connection pool shut down
  at org.apache.http.util.Asserts.check(Asserts.java:34)
  at org.apache.http.pool.AbstractConnPool.lease(AbstractConnPool.java:184)
  at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.requestConnection(PoolingHttpClientConnectionManager.java:251)
  at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:175)
  at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
  at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
  at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
  at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
  at com.aliyun.oss.common.comm.DefaultServiceClient.sendRequestCore(DefaultServiceClient.java:124)
  at com.aliyun.oss.common.comm.ServiceClient.sendRequestImpl(ServiceClient.java:133)
  ... 8 more
  • Cause

    After ossClient.shutdown() is called, requests are sent by using ossClient.

  • Solution

    Check the call logic. Make sure that no requests are sent by using ossClient after ossClient.shutdown() is called.

What do I do if the "Request has expired" error message is returned when the request is generated by using generatePresignedUrl of OSS SDK for Java?

  • Cause

    An integer overflows, which results in the Year 2038 timestamp issue.

    An upload request is initiated after the URL expires.

  • Solution

    If the integer overflows, we recommend that you set the expiration time of the URL in OSS SDK for Java to a value earlier than the year 2038.

    If you initiate an upload request after the expiration time of the URL, we recommend that you set a reasonable expiration time to ensure that the expiration time is later than the time when you initiate the request.

What do I do if the "Invalid Response" or "Implementation of JAXB-API has not been found on module path or classpath" error message is returned?

  • Cause

    Java 9 or later is installed and the dependencies on JAXB are not added.

  • Solution

    For more information about how to add the JAXB dependencies, see Installation.

Does OSS SDK for Java provide thread safety?

Yes, OSS SDK for Java provides thread safety.

What do I do if the "AccessDenied Hierarchical namespace is disabled" error message is returned?

  • Cause

    The hierarchical namespace feature is disabled before the CreateDirectory, Rename, or DeleteDirectory operation is called.

  • Solution

    Enable the hierarchical namespace feature for a bucket when you create the bucket. For more information, see Create a bucket.

What do I do if the "Connection reset" error message is returned when I access OSS over HTTP with stable client network?

Operators in specific regions may hijack OSS domain names. We recommend that you specify HTTPS when you specify the endpoint. For more information, see Configure an OSSClient instance.

What do I do if the "Java 17 Cannot invoke "java.lang.reflect.Method.invoke(Object, Object[])" because "com.sun.xml.bind.v2.runtime.reflect.opt.Injector.defineClass" is null" error message is returned?

  • Cause

    JAXB is deprecated in Java 9 and removed in Java 11.

  • Solution

    Add the following dependencies:

        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.3.1</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.messaging.saaj</groupId>
            <artifactId>saaj-impl</artifactId>
            <version>1.5.1</version>
        </dependency>

How do I configure internal logging for OSS SDK for Java?

OSS SDK for Java uses Apache Commons Logging (JCL). JCL supports different logging implementation frameworks, two of which are JCL over Log4j and JCL over SLF4J. For more information, see Configuration.

  • JCL over Log4j: Import the dependencies of Log4j and make proper configurations. Log4j 2.x supports several implementation frameworks. The default implementation framework is to use Log4j2 API and Core. For more information, see API Separation.

  • JCL over SLF4J: Import dependencies of jcl-over-slf4j and SLF4J and make proper configurations. SLF4J supports several implementation frameworks, such as the combination of slf4j-api and logback-classic. For more information, see Bridging legacy APIs.

Apache Log4j defines different log levels: OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, and ALL.

You can enable or disable logging for OSS SDK for Java by configuring the attributes of Log4j.

FAQ1

Other errors

For more information about how to resolve other errors returned by OSS, see Overview.