0

I am trying to connect to Object Storage service through android studio and i am getting this error message:

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] ERROR: No OpenStack4j connector found in classpath 03-21 15:47:19.689 31335-31335/com.example.michaelwizard.coudapp D/AndroidRuntime: Shutting down VM 03-21 15:47:19.689 31335-31335/com.example.michaelwizard.coudapp E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.michaelwizard.coudapp, PID: 31335 org.openstack4j.api.exceptions.ConnectorNotFoundException: No OpenStack4j connector found in classpath at org.openstack4j.core.transport.internal.HttpExecutor.service(HttpExecutor.java:33) at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:51) at org.openstack4j.openstack.internal.OSAuthenticator.authenticateV3(OSAuthenticator.java:156) at org.openstack4j.openstack.internal.OSAuthenticator.invoke(OSAuthenticator.java:78) at org.openstack4j.openstack.client.OSClientBuilder$ClientV3.authenticate(OSClientBuilder.java:163) at org.openstack4j.openstack.client.OSClientBuilder$ClientV3.authenticate(OSClientBuilder.java:127) at com.example.michaelwizard.coudapp.ObjectActivity.ObjectOpenStack4j(ObjectActivity.java:87) at com.example.michaelwizard.coudapp.ObjectActivity.onClick(ObjectActivity.java:104) at android.view.View.performClick(View.java:5198) at android.view.View$PerformClick.run(View.java:21147) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Here is My Code

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);

    }

And here is my graddle settings

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'
}
Michael
  • 519
  • 10
  • 18
  • Hi Michael. Help me understand please: You're building an Android application using Android Studio, but using Swift (and openstack) to call ObjectStore from within your mobile Android app? It seems to me that it might be easier to just use the REST API from within Android. I could be totally off-base here, but I've not seen Swift used in this context before. – John Gerken Jul 21 '16 at 15:20
  • @JohnGerken am really grateful for you response the documentary from ibm website is not well explanatory that is the reason why i think i need to use swift class on my IDE but i will really love it to see sample of how can i post image to iBM object storage using REST API i have search every i have not seen any sample. Thank you very much regards – Michael Jul 21 '16 at 16:37

0 Answers0