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