Hi Sajith,

In the json you've passed all images have the "Id" field, so that NPE
should not appear.

In order to see the real responses you're getting when using the
jclouds compute service, could you configure the logs and enable the
"jclouds.wire" logger [1] at debug level? That will log all the
requests/responses that are being generated and we'll be able to see
how the image list is sent back from the Docker host.


I.

[1] http://jclouds.apache.org/reference/logging/

On 23 July 2014 08:13, Sajith Kariyawasam <saj...@gmail.com> wrote:
> Hi Devs,
>
> I'm experimenting with jclouds Docker, and trying to invoke some Docker API
> calls.
>
> The code snippet of the sample client I'm using is as follows...[1]  I'm
> trying to list the images.
>
> [1]
>         Properties overrides = new Properties();
>         overrides.setProperty(Constants.PROPERTY_MAX_RETRIES, "15");
>         overrides.setProperty("jclouds.ssh.retry-auth", "true");
>         overrides.setProperty("jclouds.endpoint", "http://127.0.0.1:4243";);
>         overrides.setProperty("type","docker");
>         Iterable<Module> modules =
>                 ImmutableSet.<Module> of(new SshjSshClientModule(), new
> SLF4JLoggingModule());
>         ComputeServiceContext computeServiceContext =
> ContextBuilder.newBuilder("docker")
>                 .credentials("root","root").modules(modules)
>
> .overrides(overrides).buildView(ComputeServiceContext.class);
>         ComputeService
> computeService=computeServiceContext.getComputeService();
>         computeService.listImages();
>
>
> But when this is executed I'm getting following exception [2] , a NPE when
> doing a pre-conditions check. I did a debug through the code and found the
> values being passed to org.jclouds.docker.domain.Image constructor
> are getting null. (for eg, id, parent, created, container etc..).
> However, If I do a curl -X GET http://127.0.0.1:4243/images/json, directly
> through Docker, I'm getting all the images as the response. [3]
> Any idea what could have done wrong in the java client?
>
> [2]
>
> SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
> SLF4J: Defaulting to no-operation (NOP) logger implementation
> SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further
> details.
> Exception in thread "main" org.jclouds.http.HttpResponseException: Error
> parsing input
> {statusCode=200, message=OK, headers={Date=[Wed, 23 Jul 2014 06:00:25
> GMT]}, payload=[content=true, contentMetadata=[contentDisposition=null,
> contentEncoding=null, contentLanguage=null, contentLength=1468,
> contentMD5=null, contentType=application/json, expires=null],
> written=false]}
> at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:67)
> at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:42)
> 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.reflect.FunctionalReflection$FunctionalInvocationHandler.handleInvocation(FunctionalReflection.java:117)
> at
> com.google.common.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:87)
> at $Proxy49.inspectImage(Unknown Source)
> at
> org.jclouds.docker.compute.strategy.DockerComputeServiceAdapter.listImages(DockerComputeServiceAdapter.java:161)
> at
> org.jclouds.docker.compute.strategy.DockerComputeServiceAdapter.listImages(DockerComputeServiceAdapter.java:58)
> at
> org.jclouds.compute.config.ComputeServiceAdapterContextModule$2.get(ComputeServiceAdapterContextModule.java:121)
> at
> org.jclouds.compute.config.ComputeServiceAdapterContextModule$2.get(ComputeServiceAdapterContextModule.java:118)
> at
> org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier$SetAndThrowAuthorizationExceptionSupplierBackedLoader.load(MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.java:73)
> at
> org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier$SetAndThrowAuthorizationExceptionSupplierBackedLoader.load(MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.java:57)
> at
> com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524)
> at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317)
> at
> com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280)
> at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195)
> at com.google.common.cache.LocalCache.get(LocalCache.java:3934)
> at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938)
> at
> com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821)
> at
> org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.get(MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.java:119)
> at
> org.jclouds.compute.suppliers.ImageCacheSupplier.get(ImageCacheSupplier.java:64)
> at
> org.jclouds.compute.suppliers.ImageCacheSupplier.get(ImageCacheSupplier.java:45)
> at
> org.jclouds.compute.internal.BaseComputeService.listImages(BaseComputeService.java:377)
> at test.docker.client.MainClass.main(MainClass.java:55)
> Caused by: java.lang.NullPointerException: id
> at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:229)
> at org.jclouds.docker.domain.Image.<init>(Image.java:57)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> at
> com.google.common.reflect.Invokable$ConstructorInvokable.invokeInternal(Invokable.java:242)
> at com.google.common.reflect.Invokable.invoke(Invokable.java:102)
> at
> org.jclouds.json.internal.DeserializationConstructorAndReflectiveTypeAdapterFactory$DeserializeIntoParameterizedConstructor.newInstance(DeserializationConstructorAndReflectiveTypeAdapterFactory.java:212)
> at
> org.jclouds.json.internal.DeserializationConstructorAndReflectiveTypeAdapterFactory$DeserializeIntoParameterizedConstructor.read(DeserializationConstructorAndReflectiveTypeAdapterFactory.java:192)
> at com.google.gson.Gson.fromJson(Gson.java:803)
> at com.google.gson.Gson.fromJson(Gson.java:768)
> at com.google.gson.Gson.fromJson(Gson.java:717)
> at org.jclouds.json.internal.GsonWrapper.fromJson(GsonWrapper.java:42)
> at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:82)
> at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:76)
> at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:62)
> ... 25 more
>
>
>
>
> [3]
>
> sajith@sajith:/tmp$ curl -X GET http://127.0.0.1:4243/images/json
> [{"Created":1404164147,"Id":"58faa899733f1db4bf5722b12da74e6edf3c67c8f6d8db6559f547f9416f3c7e","ParentId":"6c3df001ea12dcf848ff51930954e2129ac8f5717ce98819237d2d5d3e8ddd25","RepoTags":["ubuntu:14.10","ubuntu:utopic"],"Size":0,"VirtualSize":195975166}
> ,{"Created":1403644956,"Id":"ea7d6801c5389e32dcf9577c3778f1eba9a1ee978db8f48020e4c479bc26e468","ParentId":"a343823119db57543086463ae7da8aaadbcef25781c0c4d121397a2550a419a6","RepoTags":["ubuntu:precise","ubuntu:12.04"],"Size":0,"VirtualSize":127478945}
> ,{"Created":1403128455,"Id":"c5881f11ded97fd2252adf93268114329e985624c5d7bb86e439a36109d1124e","ParentId":"5796a7edb16bffa3408e0f00b1b8dc0fa4651ac88b68eee5a01b088bedb9c54a","RepoTags":["ubuntu:12.10","ubuntu:quantal"],"Size":70975635,"VirtualSize":172159231}
> ,{"Created":1403128435,"Id":"463ff6be4238c14f5b88898f17b47a9cf494f9a9be7b6170c3e852568d2b0432","ParentId":"47dd6d11a49fc66a304bb679d545e64335cfb1f12dacf76c89e1cbe50af5574d","RepoTags":["ubuntu:13.04","ubuntu:raring"],"Size":70819651,"VirtualSize":169359891}
> ,{"Created":1403128415,"Id":"195eb90b534950d334188c3627f860fbdf898e224d8a0a11ec54ff453175e081","ParentId":"209ea56fda6dc2fb013e4d1e40cb678b2af91d1b54a71529f7df0bd867adc961","RepoTags":["ubuntu:saucy","ubuntu:13.10"],"Size":4411741,"VirtualSize":184716170}
> ,{"Created":1403128361,"Id":"e54ca5efa2e962582a223ca9810f7f1b62ea9b5c3975d14a5da79d3bf6020f37","ParentId":"6c37f792ddacad573016e6aea7fc9fb377127b4767ce6104c9f869314a12041e","RepoTags":["ubuntu:trusty","ubuntu:14.04","ubuntu:latest"],"Size":178365,"VirtualSize":276464769}
> ,{"Created":1398108230,"Id":"3db9c44f45209632d6050b35958829c3a2aa256d81b9a7be45b362ff85c54710","ParentId":"6cfa4d1f33fb861d4d114f43b25abd0ac737509268065cdfd69d544a59c85ab8","RepoTags":["ubuntu:lucid","ubuntu:10.04"],"Size":182964289,"VirtualSize":182964289}
>
>
>
>
> --
> Best Regards
> Sajith

Reply via email to