Sorry, I said "it works" too soon.
It did not throw exception when calling
blobStore.containerExists(bucket);
but the result is wrong. Bucket 'public' does exist.
When calling to create container, it throws exception.
I switched to jclouds 1.9.1. the result is the same.
Code:
public static void main(String args[]) {
String username = "test:tester";
String password = "testing";
Properties overrides = new Properties();
overrides.setProperty(PROPERTY_S3_VIRTUAL_HOST_BUCKETS, "false");
overrides.setProperty(PROPERTY_S3_SERVICE_PATH, "/services/Walrus");
BlobStoreContext context = ContextBuilder.newBuilder(new
S3ApiMetadata())
.endpoint("http://myserver:8080/services/Walrus")
.credentials(username, password)
.overrides(overrides)
.buildView(BlobStoreContext.class);
BlobStore blobStore = context.getBlobStore();
String bucket="public";
boolean exist = blobStore.containerExists(bucket);
System.out.println("bucket "+ bucket + " exist "+exist);
bucket="julie";
blobStore.createContainerInLocation(null, bucket); // line 41
exception is threw
exist = blobStore.containerExists(bucket);
System.out.println("bucket exist "+ bucket + " "+exist);
}
Output:
bucket public exist false
Exception in thread "main" org.jclouds.blobstore.ContainerNotFoundException:
julie not found: The specified bucket does not exist.
at
org.jclouds.s3.handlers.ParseS3ErrorFromXmlContent.refineException(ParseS3ErrorFromXmlContent.java:89)
at
org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent.handleError(ParseAWSErrorFromXmlContent.java:89)
at
org.jclouds.http.handlers.DelegatingErrorHandler.handleError(DelegatingErrorHandler.java:65)
at
org.jclouds.http.internal.BaseHttpCommandExecutorService.shouldContinue(BaseHttpCommandExecutorService.java:136)
at
org.jclouds.http.internal.BaseHttpCommandExecutorService.invoke(BaseHttpCommandExecutorService.java:105)
at
org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:90)
at
org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:73)
at
org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:44)
at
org.jclouds.rest.internal.DelegatesToInvocationFunction.handle(DelegatesToInvocationFunction.java:156)
at
org.jclouds.rest.internal.DelegatesToInvocationFunction.invoke(DelegatesToInvocationFunction.java:123)
at com.sun.proxy.$Proxy45.putBucketInRegion(Unknown Source)
at
org.jclouds.s3.blobstore.S3BlobStore.createContainerInLocation(S3BlobStore.java:375)
at
org.jclouds.s3.blobstore.S3BlobStore.createContainerInLocation(S3BlobStore.java:143)
at com.itoa.server.test.RepositoryS3.main(RepositoryS3.java:41)
Thanks!
-----Original Message-----
From: Yao, Julie
Sent: Friday, January 29, 2016 11:53 AM
To: [email protected]
Subject: RE: Use JClouds to talk to non AWS cloud with S3 API
It works now by adding following code:
overrides.setProperty(PROPERTY_S3_SERVICE_PATH, "/services/Walrus");
BlobStoreContext context = ContextBuilder.newBuilder(new S3ApiMetadata())
.endpoint("myserver:8080/services/Walrus")
....
Thanks!
-----Original Message-----
From: Yao, Julie
Sent: Friday, January 29, 2016 10:49 AM
To: [email protected]
Subject: RE: Use JClouds to talk to non AWS cloud with S3 API
Code snippet using boto:
def connect(self):
self.connection = boto.connect_s3 (
aws_access_key_id = self.access_key_id,
aws_secret_access_key = self.secret_access_key,
port = self.port,
host= self.host,
is_secure=False,
calling_format=boto.s3.connection.OrdinaryCallingFormat()
)
bucket = self.connection.get_bucket(self.container)
....
Exception stack using jclouds:
Exception in thread "main" org.jclouds.http.HttpResponseException: request:
HEAD http://myserver:8080/public HTTP/1.1 failed with response: HTTP/1.1 500
Internal Server Error
at
org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent.handleError(ParseAWSErrorFromXmlContent.java:63)
at
org.jclouds.http.handlers.DelegatingErrorHandler.handleError(DelegatingErrorHandler.java:67)
at
org.jclouds.http.internal.BaseHttpCommandExecutorService.shouldContinue(BaseHttpCommandExecutorService.java:136)
at
org.jclouds.http.internal.BaseHttpCommandExecutorService.invoke(BaseHttpCommandExecutorService.java:105)
at
org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:90)
at
org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:73)
at
org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:44)
at
org.jclouds.rest.internal.DelegatesToInvocationFunction.handle(DelegatesToInvocationFunction.java:156)
at
org.jclouds.rest.internal.DelegatesToInvocationFunction.invoke(DelegatesToInvocationFunction.java:123)
at com.sun.proxy.$Proxy45.bucketExists(Unknown Source)
at
org.jclouds.s3.blobstore.S3BlobStore.containerExists(S3BlobStore.java:130)
at com.itoa.server.test.RepositoryS3.main(RepositoryS3.java:32)
Thanks!
-----Original Message-----
From: Andrew Phillips [mailto:[email protected]]
Sent: Thursday, January 28, 2016 9:05 PM
To: [email protected]
Cc: Yao, Julie
Subject: Re: Use JClouds to talk to non AWS cloud with S3 API
Hi Julie
Could you enable wire and debug logging so we can see exactly which calls
jclouds is making [1]? Also, could you share a code snippet of how you are
successfully using boto to do the same thing? Hopefully, we can find out where
the calls from jclouds differ from what boto is doing...
Regards
ap
[1] https://jclouds.apache.org/reference/logging/