|
Problem(Abstract) |
When multiple processing threads access a Java™ database
connectivity (JDBC) resource adapter object in IBM® WebSphere® Application
Server, the Application Server might create an IndexOutOfBoundsException
exception or other exceptions. |
|
|
|
Symptom |
There are many possible symptoms that might occur.
However, if you examine the Java exception stacks in the logs for the
Application Server, you will see an exception that is similar to the
following excerpt:
Caused by: java.lang.IndexOutOfBoundsException:
Index: 0, Size:
at java.util.ArrayList.RangeCheck(ArrayList.java:572)
at java.util.ArrayList.get(ArrayList.java:347)
at com.ibm.ws.rsadapter.jdbc.
WSJdbcObject.closeChildWrappers(WSJdbcObject.java:216)
at com.ibm.ws.rsadapter.jdbc.
WSJdbcObject.close(WSJdbcObject.java:179)
...
The stack output might reveal that this code was invoked from a Java
finalize thread. This thread is closing JDBC objects or the code is
closing higher-level objects that contain references to open JDBC
objects. |
|
|
Cause |
The JDBC resource adapter code for the Application Server
requires that an application, or other middleware that is acting on behalf
of an application, only access an instance of the JDBC objects for the
Application Server from a single thread at a time. Examples of these JDBC
objects are the WSJdbcConnection, WSJdbcStatement, WSJdbcResultSet
objects.
Multiple threads can operate simultaneously on different JDBC objects that
are allocated to those threads. However, a thread cannot use a JDBC object
if the object is already allocated to another thread. If you are using the
WebSphere Relational Resource Adapter, ensure that any JDBC objects that
are opened or created by an execution thread are closed by that same
thread.
The following scenario is not allowed:
The JDBC objects are not closed by the thread that is using the object. A
reference to that JDBC object is stored in a different user object that is
closed by a finalize method during garbage collection. T
This scenario might seem to work correctly during times of low or moderate
workload. However, during heavy workload, it is more likely that a
collision will occur between activity on a thread that is calling the
finalize method and activity on a functional thread. An exception or other
thread-safety problem is likely to occur. |
|
|
Diagnosing the
problem |
Examine all of the exception stacks in the SystemOut log
or tracing log file that might be related to the error. If a finalize
method, which is called from a Java garbage collection thread, is
involved, then the scenario is similar to the previously described
scenario.
If you are not able to determine the source of the multi-threaded access
with this method, set the enableMultithreadedAccessDetection custom
property to true in the affected data source. Attempt to recreate the
problem.
When the enableMultithreadedAccessDetection custom property is set to
true, the WebSphere Relational Resource Adapter will log the DSRA8720W
message if it detects multi-threaded access to JDBC objects. Set the
property back to false when the diagnosis is complete to eliminate any
performance impacts. The enableMultithreadedAccessDetection custom
property is a method to help you diagnose the problem, but this method
does not detect all of the cases where objects are being accessed by
multiple threads. In addition to setting this custom property, verify that
your programming model is designed properly.
For more information on configuring a data source and accessing custom
properties, see "Creating and configuring a data source using the
administrative console" topic in the Information Centers for the WebSphere
Application Server and WebSphere Application Server for z/OS®
products. |
|
|
Resolving the
problem |
Redesign your applications to access JDBC objects with
single threads. If your applications are using other frameworks or
componentry that is accessing the JDBC objects with multiple threads,
refer to the support site for the componentry vendor for more information.
If the code violation is the result of a finalize method on an object that
contains references to JDBC objects in the Application Server, modify the
finalize method to not call the close method on those JDBC objects. Use
the functional path code to close those JDBC objects. |
|
|
|
|
|
Cross Reference information |
Segment |
Product |
Component |
Platform |
Version |
Edition |
Application Servers |
WebSphere Application Server for z/OS |
DB Connections/Connection Pooling |
z/OS |
6.1, 6.0.2, 6.0.1, 5.1, 5.0 |
|
|
|
|