I'm trying to upload files to Azure BLOB using Jclouds. The environment on which the server is running is Microsoft Windows Azure VM, which is running on private network. It has ports 80 and 443 open through the firewall. The following code is used to upload the files. The same code is working if I execute it from my PC:
@SuppressWarnings("nls")
public boolean upload(final String path)
{
final File file = new File(path);
FileInputStream fis = null;
BlobStoreContext context =null;
try
{
fis = new FileInputStream(file);
context = ContextBuilder.newBuilder("azureblob").credentials(this.store, this.key).buildView(BlobStoreContext.class);
final BlobStore store = context.getBlobStore();
Payload payload = new InputStreamPayload(fis);
payload.getContentMetadata().setContentLength(fis.getChannel().size());
final Blob blob = store.blobBuilder(file.getName()).payload(payload).build();
context.getBlobStore().putBlob("js-uc-osprey", blob);
return true;
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
if(context!=null)
context.close();
}
return false;
}
I get the following exception:
com.google.inject.CreationException: Guice creation errors:
1) org.jclouds.rest.RestContext<org.jclouds.azureblob.AzureBlobClient, A> cannot be used as a key; It is not fully specified.
1 error
at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:435)
at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:154)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106)
at com.google.inject.Guice.createInjector(Guice.java:95)
at org.jclouds.ContextBuilder.buildInjector(ContextBuilder.java:321)
at org.jclouds.ContextBuilder.buildInjector(ContextBuilder.java:261)
at org.jclouds.ContextBuilder.buildView(ContextBuilder.java:521)
at org.jclouds.ContextBuilder.buildView(ContextBuilder.java:501)
at com.ct.jsix.storage.service.impl.StorageServiceImpl.upload(StorageServiceImpl.java:147)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:193)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:102)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:355)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:319)
at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:72)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1040)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:976)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:363)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:483)
at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:931)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:992)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SslConnection.handle(SslConnection.java:196)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:744)
Is there any configuration to be done on the Azure VM to make this work? Please help.