Android Studio:org.openstack4j.api.exceptions.ConnectorNotFoundException:在类路径

时间:2016-03-21 14:54:49

标签: java android android-studio ibm-cloud object-storage

我正在尝试通过android studio连接到Object Storage服务,我收到此错误消息:

  

03-21 15:47:19.668 31335-31335 / com.example.michaelwizard.coudapp   I / System.out:VCAP_APPLICATION - null 03-21 15:47:19.668   31335-31335 / com.example.michaelwizard.coudapp I / System.out:   VCAP_SERVICES - null 03-21 15:47:19.688   31335-31335 / com.example.michaelwizard.coudapp W / System.err:   [org.openstack4j.core.transport.internal.HttpExecutor]错误:否   在类路径03-21 15:47:19.689中找到的OpenStack4j连接器   31335-31335 / com.example.michaelwizard.coudapp D / AndroidRuntime:   关闭VM 03-21 15:47:19.689   31335-31335 / com.example.michaelwizard.coudapp E / AndroidRuntime:致命   例外:主要                                                                                      过程:com.example.michaelwizard.coudapp,PID:31335                                                                                      org.openstack4j.api.exceptions.ConnectorNotFoundException:不   在类路径中找到OpenStack4j连接器                                                                                          在   org.openstack4j.core.transport.internal.HttpExecutor.service(HttpExecutor.java:33)                                                                                          在   org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:51)                                                                                          在   org.openstack4j.openstack.internal.OSAuthenticator.authenticateV3(OSAuthenticator.java:156)                                                                                          在   org.openstack4j.openstack.internal.OSAuthenticator.invoke(OSAuthenticator.java:78)                                                                                          在   org.openstack4j.openstack.client.OSClientBuilder $ ClientV3.authenticate(OSClientBuilder.java:163)                                                                                          在   org.openstack4j.openstack.client.OSClientBuilder $ ClientV3.authenticate(OSClientBuilder.java:127)                                                                                          在   com.example.michaelwizard.coudapp.ObjectActivity.ObjectOpenStack4j(ObjectActivity.java:87)                                                                                          在   com.example.michaelwizard.coudapp.ObjectActivity.onClick(ObjectActivity.java:104)                                                                                          在android.view.View.performClick(View.java:5198)                                                                                          在android.view.View $ PerformClick.run(View.java:21147)                                                                                          在android.os.Handler.handleCallback(Handler.java:739)                                                                                          在android.os.Handler.dispatchMessage(Handler.java:95)                                                                                          在android.os.Looper.loop(Looper.java:148)                                                                                          在android.app.ActivityThread.main(ActivityThread.java:5417)                                                                                          at java.lang.reflect.Method.invoke(Native Method)                                                                                          在   com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:726)                                                                                          在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

这是我的代码

void ObjectOpenStack4j() throws JSONException, ParseException {
        JSONParser parser = new JSONParser();
        Object obj;
        JSONArray vcapArray;
        JSONObject jsonObject
                ,vcap
                ,credentials;
        String envServices,username = null,password = null,auth_url = null,
domain = null,project = null;

        Identifier domainIdent,projectIdent;

        String envApp = System.getenv("VCAP_APPLICATION");
        System.out.println("VCAP_APPLICATION - " + envApp);
        envServices = System.getenv("VCAP_SERVICES");
        System.out.println("VCAP_SERVICES - " + envServices);

        if (envServices != null && envServices.length() > 0) {
//
        obj = parser.parse(envServices);

        System.out.println("Result: "+obj.toString());

        jsonObject = (JSONObject) obj;
        vcapArray = (JSONArray) jsonObject.get("Object-Storage");
        vcap = (JSONObject) vcapArray.get(0);
        credentials = (JSONObject) vcap.get("credentials");

            username = credentials.get("username").toString();
            password = credentials.get("password").toString();
            auth_url = credentials.get("auth_url").toString() + "/v3";
            domain = credentials.get("domainName").toString();
            project = credentials.get("project").toString();

        }else{
            username = "xxxxxxxxxxxxxxxxxx";
            password = "xxxxxxxxxxxx";
            auth_url = "https://xxxxxx.open.xxxxxx.com";
            domain = "12345";
            project = "xxxxxxxxxxxxxxxxxx";
        }


        domainIdent = Identifier.byName(domain);
        projectIdent = Identifier.byName(project);


        OSClient os = OSFactory.builderV3().endpoint(auth_url).
credentials(username, password, domainIdent).scopeToProject(projectIdent, 
domainIdent)
                .authenticate();
        SwiftAccount  account = os.objectStorage().account().get();
        System.out.println("Result: "+account);

    }

这是我的渐变设置

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.example.xxx.coudapp"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/services/com.fasterxml.jackson.core.JsonFactory'
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile(
'proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        incremental true
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    //    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.0.0-alpha1'
    compile 'com.google.code.findbugs:jsr305:3.0.1'
    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.cloudant:cloudant-sync-datastore-android:0.15.5'
    compile 'com.cloudant:cloudant-sync-datastore-javase:0.15.5'
    compile('com.googlecode.json-simple:json-simple:1.1.1') {
        exclude group: 'org.hamcrest', module: 'hamcrest-core'
    }
    compile 'org.pacesys:openstack4j-core:2.11'
    compile 'org.pacesys:openstack4j-core-test:2.11'
}

0 个答案:

没有答案