Oracle's Java Edition of the Berkeley Database seems like quite a nice system and since on Android we want to avoid using SQLite (as Daniel Wagner has found a great deal of pain there and recommends against using it). However Oracle fails at releasing products in a developer friendly way.
It can be downloaded from http://www.oracle.com/technetwork/database/berkeleydb/downloads/index.html though the normal links require login first (fail). Talk to drt24 if you don't want to give them your email. There is a maven pom listed which might result in excitement but the maven repository it is in is pretty badly broken and throws 404s for directories which have contents (rather than listing the contents) and so it is hard to mirror it into something sane. The metadata files it does have also don't list recent versions which do exist in the repository. You can get out all the content with:
wget http://download.oracle.com/maven/com/sleepycat/je/5.0.34/je-5.0.34{.jar,.jar.md5,.jar.sha1,.pom,.pom.md5,.pom.sha1,-sources.jar,-sources.jar.md5,-sources.jar.sha1,-javadoc.jar,-javadoc.jar.md5,-javadoc.jar.sha1}
and then upload them to your local repository (we have a nexus install, talk to drt24 for access). However if you want to use android you will need to get the je-android-$VERSION.jar file out of the release tar.gz and upload that (use an android classifier). The problem here is that the android version of the library does not work on a normal JVM and the normal version does not work on the android dalvik JVM. Hence pain. If you use the android version on a normal JVM you get something like:
java.lang.ExceptionInInitializerError at com.sleepycat.je.dbi.EnvironmentImpl.<init>(EnvironmentImpl.java:444) at com.sleepycat.je.dbi.EnvironmentImpl.<init>(EnvironmentImpl.java:376) at com.sleepycat.je.dbi.DbEnvPool.getEnvironment(DbEnvPool.java:180) at com.sleepycat.je.Environment.makeEnvironmentImpl(Environment.java:246) at com.sleepycat.je.Environment.<init>(Environment.java:227) at com.sleepycat.je.Environment.<init>(Environment.java:170) [snip app specific stuff] Caused by: java.lang.NullPointerException at com.sleepycat.je.dbi.MemoryBudget.<clinit>(MemoryBudget.java:500) ... 34 more
If you use he normal version on the android JVM you get something like:
W/dalvikvm(26019): Exception Lcom/sleepycat/je/EnvironmentFailureException; thrown while initializing Lcom/sleepycat/je/log/LogEntryType;
D/AndroidRuntime(26019): Shutting down VM
W/dalvikvm(26019): threadid=1: thread exiting with uncaught exception (group=0x40015560)
E/AndroidRuntime(26019): FATAL EXCEPTION: main
E/AndroidRuntime(26019): java.lang.ExceptionInInitializerError
E/AndroidRuntime(26019): at com.sleepycat.je.dbi.EnvironmentImpl.logMapTreeRoot(EnvironmentImpl.java:1154)
E/AndroidRuntime(26019): at com.sleepycat.je.dbi.EnvironmentImpl.logMapTreeRoot(EnvironmentImpl.java:1140)
E/AndroidRuntime(26019): at com.sleepycat.je.recovery.RecoveryManager.recover(RecoveryManager.java:202)
E/AndroidRuntime(26019): at com.sleepycat.je.dbi.EnvironmentImpl.finishInit(EnvironmentImpl.java:604)
E/AndroidRuntime(26019): at com.sleepycat.je.dbi.DbEnvPool.getEnvironment(DbEnvPool.java:210)
E/AndroidRuntime(26019): at com.sleepycat.je.Environment.makeEnvironmentImpl(Environment.java:246)
E/AndroidRuntime(26019): at com.sleepycat.je.Environment.<init>(Environment.java:227)
E/AndroidRuntime(26019): at com.sleepycat.je.Environment.<init>(Environment.java:170)
E/AndroidRuntime(26019): at com.google.nigori.server.JEDatabase.<init>(JEDatabase.java:65)
[snip app specific stuff]
E/AndroidRuntime(26019): Caused by: com.sleepycat.je.EnvironmentFailureException: (JE 5.0.34) java.lang.NoSuchMethodException UNEXPECTED_EXCEPTION: Unexpected internal Exception, may have side effects.
E/AndroidRuntime(26019): at com.sleepycat.je.log.entry.BaseEntry.getNoArgsConstructor(BaseEntry.java:61)
E/AndroidRuntime(26019): at com.sleepycat.je.log.entry.BaseEntry.<init>(BaseEntry.java:52)
E/AndroidRuntime(26019): at com.sleepycat.je.log.entry.SingleItemEntry.<init>(SingleItemEntry.java:36)
E/AndroidRuntime(26019): at com.sleepycat.je.log.LogEntryType.<clinit>(LogEntryType.java:431)
E/AndroidRuntime(26019): ... 26 more
E/AndroidRuntime(26019): Caused by: java.lang.NoSuchMethodException
E/AndroidRuntime(26019): at java.lang.Class.getDeclaredConstructors(Native Method)
E/AndroidRuntime(26019): at java.lang.Class.getConstructor(Class.java:472)
E/AndroidRuntime(26019): at com.sleepycat.je.log.entry.BaseEntry.getNoArgsConstructor(BaseEntry.java:57)
E/AndroidRuntime(26019): ... 29 more
The solution to this (in maven terms is):
<dependency>
<groupId>uk.ac.cam.cl.passgori</groupId>
<artifactId>library</artifactId>
<version>0.0.1-SNAPSHOT</version>
<exclusions>
<!-- Need to use the android version of the library -->
<exclusion>
<artifactId>je</artifactId>
<groupId>com.sleepycat</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sleepycat</groupId>
<artifactId>je</artifactId>
<version>5.0.34</version>
<classifier>android</classifier>
</dependency>
where here the dependency on library is what is pulling in the normal version of the com.sleepycat.je library and so we exclude it there in order to include a different version explicitly.
