java - MongoLab Connection Issues in Android App Using MongoDB Async Driver 3.0.2 -
simply put can't connect. i've followed documentation , seem getting lots of errors.
errors
05-31 15:26:24.062 15970-15970/com.example.android.slidingtabsbasic w/dalvikvm﹕ vfy: unable resolve static method 18243: ljavax/management/objectname;.quote (ljava/lang/string;)ljava/lang/string; 05-31 15:26:24.062 15970-15970/com.example.android.slidingtabsbasic w/dalvikvm﹕ vfy: unable resolve static method 17794: ljava/lang/management/managementfactory;.getruntimemxbean ()ljava/lang/management/runtimemxbean; 05-31 15:26:24.092 15970-15970/com.example.android.slidingtabsbasic w/org.bson.objectid﹕ failed process identifier jmx, using random number instead java.lang.noclassdeffounderror: java.lang.management.managementfactory @ org.bson.types.objectid.createprocessidentifier(objectid.java:502) @ org.bson.types.objectid.<clinit>(objectid.java:460) @ com.mongodb.connection.clusterid.<init>(clusterid.java:47) @ com.mongodb.connection.defaultclusterfactory.create(defaultclusterfactory.java:40) @ com.mongodb.async.client.mongoclients.createcluster(mongoclients.java:96) @ com.mongodb.async.client.mongoclients.create(mongoclients.java:55) @ com.mongodb.async.client.mongoclients.create(mongoclients.java:75) @ com.mongodb.async.client.mongoclients.create(mongoclients.java:65) @ com.example.android.slidingtabsbasic.mainactivity.mongodbconnection(mainactivity.java:287) @ com.example.android.slidingtabsbasic.mainactivity.oncreate(mainactivity.java:101) @ android.app.activity.performcreate(activity.java:5234) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1082) @ android.app.activitythread.performlaunchactivity(activitythread.java:2045) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2106) @ android.app.activitythread.access$600(activitythread.java:138) @ android.app.activitythread$h.handlemessage(activitythread.java:1204) @ android.os.handler.dispatchmessage(handler.java:99) @ android.os.looper.loop(looper.java:137) @ android.app.activitythread.main(activitythread.java:4921) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:511) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:790) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:557) @ dalvik.system.nativestart.main(native method) 05-31 15:26:24.092 15970-15970/com.example.android.slidingtabsbasic i/cluster﹕ cluster created settings {hosts=[ds043082.mongolab.com:43082], mode=single, requiredclustertype=unknown, serverselectiontimeout='30000 ms', maxwaitqueuesize=500} 05-31 15:26:24.102 15970-15970/com.example.android.slidingtabsbasic w/dalvikvm﹕ vfy: unable resolve static method 17793: ljava/lang/management/managementfactory;.getplatformmbeanserver ()ljavax/management/mbeanserver; 05-31 15:26:24.102 15970-15970/com.example.android.slidingtabsbasic e/dalvikvm﹕ not find class 'javax.management.objectname', referenced method com.mongodb.internal.management.jmx.jmxmbeanserver.registermbean 05-31 15:26:24.102 15970-15970/com.example.android.slidingtabsbasic w/dalvikvm﹕ vfy: unable resolve new-instance 2774 (ljavax/management/objectname;) in lcom/mongodb/internal/management/jmx/jmxmbeanserver; 05-31 15:26:24.102 15970-15970/com.example.android.slidingtabsbasic e/dalvikvm﹕ not find class 'javax.management.objectname', referenced method com.mongodb.internal.management.jmx.jmxmbeanserver.unregistermbean 05-31 15:26:24.102 15970-15970/com.example.android.slidingtabsbasic w/dalvikvm﹕ vfy: unable resolve new-instance 2774 (ljavax/management/objectname;) in lcom/mongodb/internal/management/jmx/jmxmbeanserver; 05-31 15:26:24.112 15970-15970/com.example.android.slidingtabsbasic i/cluster﹕ no server chosen readpreferenceserverselector{readpreference=primary} cluster description clusterdescription{type=unknown, connectionmode=single, all=[serverdescription{address=ds043082.mongolab.com:43082, type=unknown, state=connecting}]}. waiting 30000 ms before timing out 05-31 15:26:24.112 15970-15983/com.example.android.slidingtabsbasic w/dalvikvm﹕ vfy: unable find class referenced in signature (ljava/nio/channels/asynchronoussocketchannel;) 05-31 15:26:24.112 15970-15983/com.example.android.slidingtabsbasic w/dalvikvm﹕ vfy: unable resolve virtual method 17891: ljava/nio/channels/asynchronoussocketchannel;.close ()v 05-31 15:26:24.112 15970-15983/com.example.android.slidingtabsbasic w/dalvikvm﹕ vfy: unable resolve static method 17893: ljava/nio/channels/asynchronoussocketchannel;.open ()ljava/nio/channels/asynchronoussocketchannel; 05-31 15:26:24.112 15970-15983/com.example.android.slidingtabsbasic w/dalvikvm﹕ link of class 'lcom/mongodb/connection/asynchronoussocketchannelstream$basiccompletionhandler;' failed 05-31 15:26:24.112 15970-15983/com.example.android.slidingtabsbasic e/dalvikvm﹕ not find class 'com.mongodb.connection.asynchronoussocketchannelstream$basiccompletionhandler', referenced method com.mongodb.connection.asynchronoussocketchannelstream.readasync 05-31 15:26:24.112 15970-15983/com.example.android.slidingtabsbasic w/dalvikvm﹕ vfy: unable resolve new-instance 1973 (lcom/mongodb/connection/asynchronoussocketchannelstream$basiccompletionhandler;) in lcom/mongodb/connection/asynchronoussocketchannelstream; 05-31 15:26:24.112 15970-15983/com.example.android.slidingtabsbasic w/dalvikvm﹕ link of class 'lcom/mongodb/connection/asynchronoussocketchannelstream$1;' failed 05-31 15:26:24.112 15970-15983/com.example.android.slidingtabsbasic w/dalvikvm﹕ link of class 'lcom/mongodb/connection/asynchronoussocketchannelstream$1;' failed 05-31 15:26:24.112 15970-15983/com.example.android.slidingtabsbasic w/dalvikvm﹕ link of class 'lcom/mongodb/connection/asynchronoussocketchannelstream$basiccompletionhandler;' failed 05-31 15:26:24.122 15970-15983/com.example.android.slidingtabsbasic i/cluster﹕ exception in monitor thread while connecting server ds043082.mongolab.com:43082 com.mongodb.mongointernalexception: opening asynchronoussocketchannelstream failed @ com.mongodb.connection.futureasynccompletionhandler.get(futureasynccompletionhandler.java:65) @ com.mongodb.connection.futureasynccompletionhandler.getopen(futureasynccompletionhandler.java:43) @ com.mongodb.connection.asynchronoussocketchannelstream.open(asynchronoussocketchannelstream.java:60) @ com.mongodb.connection.internalstreamconnection.open(internalstreamconnection.java:114) @ com.mongodb.connection.defaultservermonitor$servermonitorrunnable.run(defaultservermonitor.java:127) @ java.lang.thread.run(thread.java:856) caused by: java.lang.noclassdeffounderror: java.nio.channels.asynchronoussocketchannel @ com.mongodb.connection.asynchronoussocketchannelstream.openasync(asynchronoussocketchannelstream.java:67) @ com.mongodb.connection.asynchronoussocketchannelstream.open(asynchronoussocketchannelstream.java:59) at com.mongodb.connection.internalstreamconnection.open(internalstreamconnection.java:114) at com.mongodb.connection.defaultservermonitor$servermonitorrunnable.run(defaultservermonitor.java:127) at java.lang.thread.run(thread.java:856) 05-31 15:26:54.114 15970-15984/com.example.android.slidingtabsbasic i/system.out﹕ operation finished! 05-31 15:26:54.134 15970-15984/com.example.android.slidingtabsbasic i/system.out﹕ listdatabasenames() errored: timed out after 30000 ms while waiting server matches readpreferenceserverselector{readpreference=primary}. client view of cluster state {type=unknown, servers=[{address=ds043082.mongolab.com:43082, type=unknown, state=connecting, exception={com.mongodb.mongointernalexception: opening asynchronoussocketchannelstream failed}, caused {java.lang.noclassdeffounderror: java.nio.channels.asynchronoussocketchannel}}] 05-31 15:26:54.194 15970-16200/com.example.android.slidingtabsbasic d/libc﹕ [net] no pids match num= 99 05-31 15:26:54.314 15970-15970/com.example.android.slidingtabsbasic i/mainactivity﹕ ready 05-31 15:26:54.404 15970-15970/com.example.android.slidingtabsbasic i/cluster﹕ cluster created settings {hosts=[ds043082.mongolab.com:43082], mode=single, requiredclustertype=unknown, serverselectiontimeout='30000 ms', maxwaitqueuesize=500} 05-31 15:26:54.404 15970-15970/com.example.android.slidingtabsbasic i/cluster﹕ no server chosen readpreferenceserverselector{readpreference=primary} cluster description clusterdescription{type=unknown, connectionmode=single, all=[serverdescription{address=ds043082.mongolab.com:43082, type=unknown, state=connecting}]}. waiting 30000 ms before timing out 05-31 15:26:54.404 15970-16215/com.example.android.slidingtabsbasic i/cluster﹕ exception in monitor thread while connecting server ds043082.mongolab.com:43082 com.mongodb.mongointernalexception: opening asynchronoussocketchannelstream failed @ com.mongodb.connection.futureasynccompletionhandler.get(futureasynccompletionhandler.java:65) @ com.mongodb.connection.futureasynccompletionhandler.getopen(futureasynccompletionhandler.java:43) @ com.mongodb.connection.asynchronoussocketchannelstream.open(asynchronoussocketchannelstream.java:60) @ com.mongodb.connection.internalstreamconnection.open(internalstreamconnection.java:114) @ com.mongodb.connection.defaultservermonitor$servermonitorrunnable.run(defaultservermonitor.java:127) @ java.lang.thread.run(thread.java:856) caused by: java.lang.noclassdeffounderror: java.nio.channels.asynchronoussocketchannel @ com.mongodb.connection.asynchronoussocketchannelstream.openasync(asynchronoussocketchannelstream.java:67) @ com.mongodb.connection.asynchronoussocketchannelstream.open(asynchronoussocketchannelstream.java:59) at com.mongodb.connection.internalstreamconnection.open(internalstreamconnection.java:114) at com.mongodb.connection.defaultservermonitor$servermonitorrunnable.run(defaultservermonitor.java:127) at java.lang.thread.run(thread.java:856) 05-31 15:26:54.414 15970-15970/com.example.android.slidingtabsbasic i/cluster﹕ cluster created settings {hosts=[ds043082.mongolab.com:43082], mode=single, requiredclustertype=unknown, serverselectiontimeout='30000 ms', maxwaitqueuesize=500} 05-31 15:26:54.424 15970-15970/com.example.android.slidingtabsbasic i/cluster﹕ no server chosen readpreferenceserverselector{readpreference=primary} cluster description clusterdescription{type=unknown, connectionmode=single, all=[serverdescription{address=ds043082.mongolab.com:43082, type=unknown, state=connecting}]}. waiting 30000 ms before timing out 05-31 15:26:54.434 15970-16217/com.example.android.slidingtabsbasic i/cluster﹕ exception in monitor thread while connecting server ds043082.mongolab.com:43082 com.mongodb.mongointernalexception: opening asynchronoussocketchannelstream failed @ com.mongodb.connection.futureasynccompletionhandler.get(futureasynccompletionhandler.java:65) @ com.mongodb.connection.futureasynccompletionhandler.getopen(futureasynccompletionhandler.java:43) @ com.mongodb.connection.asynchronoussocketchannelstream.open(asynchronoussocketchannelstream.java:60) @ com.mongodb.connection.internalstreamconnection.open(internalstreamconnection.java:114) @ com.mongodb.connection.defaultservermonitor$servermonitorrunnable.run(defaultservermonitor.java:127) @ java.lang.thread.run(thread.java:856) caused by: java.lang.noclassdeffounderror: java.nio.channels.asynchronoussocketchannel @ com.mongodb.connection.asynchronoussocketchannelstream.openasync(asynchronoussocketchannelstream.java:67) @ com.mongodb.connection.asynchronoussocketchannelstream.open(asynchronoussocketchannelstream.java:59) at com.mongodb.connection.internalstreamconnection.open(internalstreamconnection.java:114) at com.mongodb.connection.defaultservermonitor$servermonitorrunnable.run(defaultservermonitor.java:127) at java.lang.thread.run(thread.java:856) 05-31 15:26:54.454 15970-15970/com.example.android.slidingtabsbasic i/adreno200-egl﹕ <qegldrvapi_eglinitialize:269>: egl 1.4 qualcomm build: (cl2858274) build date: 12/24/12 mon local branch: d1l_vwz1211_rb4_au37-1738j remote branch: local patches: reconstruct branch:
here code i'm executing attempt make connection. i'm confused weather or not need provide login information connection string? have tried both , both result in errors i'd know when i'd use credentials , when wouldn't?
public void mongodbconnection() throws interruptedexception{ //makes connection database mongoclient = mongoclients.create("mongodb://xxx:xxx**x@theconnection/database"); final countdownlatch latch = new countdownlatch(1); singleresultcallback<void> callbackwhenfinished = new singleresultcallback<void>() { @override public void onresult(final void result, final throwable t) { system.out.println("operation finished!"); if (t != null) { system.out.println("listdatabasenames() errored: " + t.getmessage()); } latch.countdown(); } }; mongoclient.listdatabasenames().foreach(new block<string>() { @override public void apply(final string s) { system.out.println(s); } }, callbackwhenfinished); latch.await(); db = mongoclient.getdatabase("le_users"); //gets table userdatacollection = db.getcollection("userdata"); }
manfiest permissions
<uses-permission android:name="android.permission.internet"/> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.access_wifi_state" /> <uses-permission android:name="android.permission.access_coarse_location"/> <uses-permission android:name="android.permission.access_fine_location"/> <uses-permission android:name="android.permission.write_external_storage" />
called in oncreate this
try { mongodbconnection(); } catch(exception e) { e.printstacktrace(); }
the asynchronous java driver relies on asynchronoussocketchannel class, introduced in java 7, , stack trace appears that class in not available, @ least not in version of android on you're testing.
the asynchronous driver can used netty alternative asynchronoussocketchannel, might give try. in 3.0 driver requires setting of "org.mongodb.async.type" system property "netty", in 3.1 there way programmatically well.
Comments
Post a Comment