| 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 6 | <title>Java FAQ</title> |
| 7 | <link rel="stylesheet" href="gettingStarted.css" type="text/css" /> |
| 8 | <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> |
| 9 | <link rel="start" href="index.html" title="Berkeley DB Programmer's Reference Guide" /> |
| 10 | <link rel="up" href="java.html" title="Chapter 5. Java API" /> |
| 11 | <link rel="prev" href="java_program.html" title="Java programming notes" /> |
| 12 | <link rel="next" href="csharp.html" title="Chapter 6. C# API" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div xmlns="" class="navheader"> |
| 16 | <div class="libver"> |
| 17 | <p>Library Version 11.2.5.3</p> |
| 18 | </div> |
| 19 | <table width="100%" summary="Navigation header"> |
| 20 | <tr> |
| 21 | <th colspan="3" align="center">Java FAQ</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="java_program.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 5. |
| 26 | Java API |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="csharp.html">Next</a></td> |
| 29 | </tr> |
| 30 | </table> |
| 31 | <hr /> |
| 32 | </div> |
| 33 | <div class="sect1" lang="en" xml:lang="en"> |
| 34 | <div class="titlepage"> |
| 35 | <div> |
| 36 | <div> |
| 37 | <h2 class="title" style="clear: both"><a id="java_faq"></a>Java FAQ</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <div class="orderedlist"> |
| 42 | <ol type="1"> |
| 43 | <li> |
| 44 | <span class="bold"> |
| 45 | <strong>On what platforms is the Berkeley DB Java API supported?</strong> |
| 46 | </span> |
| 47 | <p>All platforms supported by Berkeley DB that have a JVM compatible with J2SE |
| 48 | 1.4 or above.</p> |
| 49 | </li> |
| 50 | <li> |
| 51 | <span class="bold"> |
| 52 | <strong>How does the Berkeley DB Java API relate to the J2EE standard?</strong> |
| 53 | </span> |
| 54 | <p>The Berkeley DB Java API does not currently implement any part of the J2EE |
| 55 | standard. That said, it does implement the implicit standard for Java |
| 56 | <a class="ulink" href="http://download.oracle.com/javase/1.5.0/docs/guide/collections/" target="_top">Java Collections</a>. The concept of a transaction exists in several |
| 57 | Java packages (J2EE, XA, JINI to name a few). Support for these APIs |
| 58 | will be added based on demand in future versions of Berkeley DB.</p> |
| 59 | </li> |
| 60 | <li> |
| 61 | <span class="bold"> |
| 62 | <strong>How should I incorporate db.jar and the db native library into |
| 63 | a Tomcat or other J2EE application servers?</strong> |
| 64 | </span> |
| 65 | <p>Tomcat and other J2EE application servers have the ability to rebuild |
| 66 | and reload code automatically. When using Tomcat this is the case when |
| 67 | "reloadable" is set to "true". If your WAR file includes the db.jar it |
| 68 | too will be reloaded each time your code is reloaded. This causes |
| 69 | exceptions as the native library can't be loaded more than once and |
| 70 | there is no way to unload native code. The solution is to place the |
| 71 | db.jar in $TOMCAT_HOME/common/lib and let Tomcat load that library once |
| 72 | at start time rather than putting it into the WAR that gets reloaded |
| 73 | over and over.</p> |
| 74 | </li> |
| 75 | <li> |
| 76 | <span class="bold"> |
| 77 | <strong>Can I use the Berkeley DB Java API from within a EJB, a Servlet or a |
| 78 | JSP page?</strong> |
| 79 | </span> |
| 80 | <p>Yes. The Berkeley DB Java API can be used from within all the popular J2EE |
| 81 | application servers in many different ways.</p> |
| 82 | </li> |
| 83 | <li> |
| 84 | <span class="bold"> |
| 85 | <strong>During one of the first calls to the Berkeley DB Java API, a |
| 86 | DbException is thrown with a "Bad file number" or "Bad file descriptor" |
| 87 | message.</strong> |
| 88 | </span> |
| 89 | <p>There are known large-file support bugs under JNI in various releases |
| 90 | of the JDK. Please upgrade to the latest release of the JDK, and, if |
| 91 | that does not solve the problem, disable big file support using the |
| 92 | --disable-largefile configuration option.</p> |
| 93 | </li> |
| 94 | <li> |
| 95 | <span class="bold"> |
| 96 | <strong>How can I use native methods from a debug build of the |
| 97 | Java library?</strong> |
| 98 | </span> |
| 99 | <p>Set Java's library path so that the debug version of Berkeley DB's Java |
| 100 | library appears, but the release version does not. Berkeley DB tries to load |
| 101 | the release library first, and if that fails tries the debug library.</p> |
| 102 | </li> |
| 103 | <li> |
| 104 | <span class="bold"> |
| 105 | <strong>Why is ClassNotFoundException thrown when adding a record to |
| 106 | the database, when a SerialBinding is used?</strong> |
| 107 | </span> |
| 108 | <p>This problem occurs if you copy the db.jar file into the Java extensions |
| 109 | (ext) directory. This will cause the database code to run under the |
| 110 | System class loader, and it won't be able to find your application |
| 111 | classes.</p> |
| 112 | <p>You'll have to actually remove db.jar from the Java extension directory. |
| 113 | If you have more than one installation of Java, be sure to remove it |
| 114 | from all of them. This is necessary even if db.jar is specified in the |
| 115 | classpath.</p> |
| 116 | <p>An example of the exception is:</p> |
| 117 | <pre class="programlisting">collections.ship.basic.SupplierKey |
| 118 | at java.net.URLClassLoader$1.run(Unknown Source) |
| 119 | at java.security.AccessController.doPrivileged(Native Method) |
| 120 | at java.net.URLClassLoader.findClass(Unknown Source) |
| 121 | at java.lang.ClassLoader.loadClass(Unknown Source) |
| 122 | at java.lang.ClassLoader.loadClass(Unknown Source) |
| 123 | at java.lang.ClassLoader.loadClassInternal(Unknown Source) |
| 124 | at java.lang.Class.forName0(Native Method) |
| 125 | at java.lang.Class.forName(Unknown Source) |
| 126 | at com.sleepycat.bind.serial.StoredClassCatalog. |
| 127 | getClassInfo(StoredClassCatalog.java:211) |
| 128 | ...</pre> |
| 129 | </li> |
| 130 | <li> |
| 131 | <span class="bold"> |
| 132 | <strong>I'm upgrading my Java application to Berkeley DB 4.3. Can I use the |
| 133 | com.sleepycat.db.internal package rather than porting my code to the new |
| 134 | API?</strong> |
| 135 | </span> |
| 136 | <p>While it is possible to use the low-level API from applications, there |
| 137 | are some caveats that should be considered when upgrading. The first is |
| 138 | that the internal API depends on some classes in the public API such as |
| 139 | DatabaseEntry.</p> |
| 140 | <p>In addition, the internal API is closer to the C API and doesn't have |
| 141 | some of the default settings that were part of the earlier Java API. |
| 142 | For example, applications will need to set the DB_THREAD flag explicitly |
| 143 | if handles are to be used from multiple threads, or subtle errors may |
| 144 | occur.</p> |
| 145 | </li> |
| 146 | </ol> |
| 147 | </div> |
| 148 | </div> |
| 149 | <div class="navfooter"> |
| 150 | <hr /> |
| 151 | <table width="100%" summary="Navigation footer"> |
| 152 | <tr> |
| 153 | <td width="40%" align="left"><a accesskey="p" href="java_program.html">Prev</a> </td> |
| 154 | <td width="20%" align="center"> |
| 155 | <a accesskey="u" href="java.html">Up</a> |
| 156 | </td> |
| 157 | <td width="40%" align="right"> <a accesskey="n" href="csharp.html">Next</a></td> |
| 158 | </tr> |
| 159 | <tr> |
| 160 | <td width="40%" align="left" valign="top">Java programming notes </td> |
| 161 | <td width="20%" align="center"> |
| 162 | <a accesskey="h" href="index.html">Home</a> |
| 163 | </td> |
| 164 | <td width="40%" align="right" valign="top"> Chapter 6. C# API</td> |
| 165 | </tr> |
| 166 | </table> |
| 167 | </div> |
| 168 | </body> |
| 169 | </html> |