jClouds SDK fails to fetch users and responds as "resource not found"

asked 2016-11-03 03:57:57 -0600

shshnk94 gravatar image


My code is supposed to reset the credential of an user for which I have to obtain the particular user. When tried with the code mentioned below I'm getting a HTTP response as the user is not available though it's present. My Openstack Version 2 is set up using Devstack and I'm using Apache jClouds Java SDK.

import java.io.Closeable;
import java.io.IOException;
import java.util.NoSuchElementException;

import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
import org.jclouds.openstack.keystone.v2_0.domain.User;
import org.jclouds.openstack.keystone.v2_0.extensions.UserAdminApi;
import org.jclouds.openstack.keystone.v2_0.features.UserApi;
import org.jclouds.openstack.keystone.v2_0.options.UpdateUserOptions;
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;

import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;
import com.google.common.io.Closeables;
import com.google.inject.Module;

import org.jclouds.ContextBuilder;
import org.jclouds.collect.PagedIterable;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;

public class OpenStackPasswordReset_jClouds implements Closeable{
    private KeystoneApi keyStoneApi = null;
    public static void main(String[] args) {
        OpenStackPasswordReset_jClouds ospr = new OpenStackPasswordReset_jClouds();

        try {
        } catch (IOException e) {
            // ignore

    public void ResetUserPassword() {

        Iterable<Module> modules = ImmutableSet.<Module>of(new SLF4JLoggingModule());

        String provider = "openstack-keystone";
        String identity = "demo:admin"; // tenantName:userName
        String credential = <password>;
        UpdateUserOptions options = UpdateUserOptions.Builder.password(<new_password>).email(<email>).enabled(true);

        try {
            keyStoneApi = ContextBuilder.newBuilder(provider)
                    .credentials(identity, credential)

            Optional<? extends UserAdminApi> usrAdminApi = keyStoneApi.getUserAdminApi();
            Optional<? extends UserApi> usrApi = keyStoneApi.getUserApi();
            if (usrApi.isPresent() && usrAdminApi.isPresent())
                User usr1 = usrApi.get().getByName("admin")
            else {
                System.out.println("ERROR: Unable to get services to reset user password.");
        } catch (Exception e) {
            System.out.println("ERROR: Failed to reset user password");


    public void close() throws IOException {


I've also attached the error log below. The authentication is working fine as I could obtain the token but fetching user/user list throws the following error.

12:00:00.048 [main] DEBUG org.jclouds.rest.internal.InvokeHttpMethod - >> invoking extension:list
12:00:00.075 [main] DEBUG org.jclouds.rest.internal.InvokeHttpMethod - >> invoking AuthenticationApi.authenticateWithTenantNameAndCredentials
12:00:00.076 [main] DEBUG org.jclouds.http.internal.JavaUrlHttpCommandExecutorService - Sending request 1216299359: POST HTTP/1.1
12:00:00.076 [main] DEBUG jclouds.wire - >> "{"auth":{"passwordCredentials":{"username":"admin","password":"<password>"},"tenantName":"demo"}}"
12:00:00.077 [main] DEBUG jclouds.headers - >> POST HTTP/1.1
12:00:00.077 [main] DEBUG jclouds.headers - >> Accept: application/json
12:00:00.077 [main] DEBUG jclouds.headers - >> Content-Type: application/json
12:00:00.077 [main] DEBUG jclouds.headers - >> Content-Length: 93
12:00:00.844 [main] DEBUG org.jclouds.http.internal.JavaUrlHttpCommandExecutorService - Receiving response 1216299359: HTTP/1.1 200 OK
12:00:00.844 [main] DEBUG jclouds.headers - << HTTP/1.1 200 OK
12:00:00.845 [main] DEBUG jclouds.headers - << Keep-Alive: timeout=5 ...
edit retag flag offensive close merge delete