[JAVA-295] Support Android platform Created: 11/Mar/11 Updated: 29/Aug/12 Resolved: 02/Aug/12 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API |
| Affects Version/s: | 2.3, 2.4, 2.5 |
| Fix Version/s: | 2.9.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Angelos Kapsimanis | Assignee: | Jeffrey Yemin |
| Resolution: | Done | Votes: | 2 |
| Labels: | android | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Eclipse Helios Service Release 1, mongodb 1.6.5, Android SDK version 7/release 2, Windows XP SP3, Windows Vista SP2 |
||
| Issue Links: |
|
||||||||
| Description |
|
Hello to everybody, I am facing the following problem: I am trying to use the java driver within the android SDK and it gets crashed when use it as a precompiled jar (ver. 2.3, ver.2.4, ver.2.5) Here is the stack trace: 03-11 22:38:17.320: INFO/dalvikvm(230): Could not find method java.lang.management.ManagementFactory.getRuntimeMXBean, referenced from method org.bson.types.ObjectId.<clinit> I have tried to use the source code in the project but depends on the MBeanServer component and the java.lang.management package , hence it can't be compiled for dalvik because of their absence. The exception is thrown from the file ObjectId.class where I read in jira.mongodb.org/browse/ Any help is greatly apreciated. |
| Comments |
| Comment by Jeffrey Yemin [ 29/Aug/12 ] | |||||||||||||||||
|
Closing as part of 2.9.0 release process. | |||||||||||||||||
| Comment by auto [ 02/Aug/12 ] | |||||||||||||||||
|
Author: {u'date': u'2012-05-02T06:54:21-07:00', u'email': u'jeff.yemin@10gen.com', u'name': u'Jeff Yemin'}Message: | |||||||||||||||||
| Comment by Jeffrey Yemin [ 01/Aug/12 ] | |||||||||||||||||
|
I've re-evaluated the API change required for this, and I don't think it's significant enough to require a major release. SimplePool class is public but in practice should not really be used by any clients. Moving to 2.9.0. | |||||||||||||||||
| Comment by auto [ 25/May/12 ] | |||||||||||||||||
|
Author: {u'login': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: | |||||||||||||||||
| Comment by Jeffrey Yemin [ 02/May/12 ] | |||||||||||||||||
|
I got the driver to run on Android in the emulator by replacing DynamicMBean with SimplePoolMBean. But the change is not backwards compatible so it will have to wait for a major release. | |||||||||||||||||
| Comment by Jeffrey Yemin [ 01/May/12 ] | |||||||||||||||||
|
I tried this out, and it does seem like the VM is being overly aggressive in its classloading. I tried this change to DBPortPool.Holder and it helped:
But then I ran into another problem. com.mongodb.util.SimplePool implements javax.management.DynamicMBean, and so I get this error:
| |||||||||||||||||
| Comment by Jeffrey Yemin [ 28/Apr/12 ] | |||||||||||||||||
|
Apologies that this has been left unattended for so long. But I'm unsure what we can do about this without removing JMX entirely or resorting to reflection, which has its own risks (as it can be prevented by the security manager). Using the standard Sun VM, the technique used to fix
Run this code without mongo-java-driver in the classpath and you get this output:
which demonstrates that the VM waits until the actual point of call before attempting to load the class. It's possible that Dalvik is doing this differently. Can any Android developers confirm this with a full stack trace of the exception? | |||||||||||||||||
| Comment by Samuel Kroslak [ 17/May/11 ] | |||||||||||||||||
|
Hello, this is probably related to: and the issue is marked as fixed in: I see this was planned for 2.6 but was postponed to 2.7, so my question: is there anything I can do, if I want to use mongodb java driver on android? now when I try to use it it throws: I've tried downloading the code and to get rid of all references to java.lang.management.* and javax.management.* |