Hi,
Here is a Simple demonstration of Debugging Jdbc N/W Connectivity issues. Some very basic and common tools and simple Jdbc programs helps us a lot in debugging the JDBC issues.
You can also refer to the WebLogic JDBC related some very common tips: http://weblogic-wonders.com/weblogic/2010/02/10/jdbc-tips/
Common Jdbc Issues-1).
If you get the following Error:
<BEA-149205> <Failed to initialize the application ‘TestDataSource’ due to error weblogic.application.ModuleException: .
weblogic.application.ModuleException:
at weblogic.jdbc.module.JDBCModule.prepare(JDBCModule.java:289)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:387)
.
.
weblogic.common.ResourceException: Could not create pool connection. The DBMS driver exception was: The Network Adapter could not establish the connection
- – - – - – or - – - – - -
weblogic.common.ResourceException: weblogic.common.ResourceException: Could not create pool connection. The DBMS driver exception was: Io exception: The Network Adapter
Degugging the root Cause of above Issue:
The Above Exception: java.io.IOException: The Network Adapter could not establish the connection
It simply suggest that the Database URL may not be correct in the DataSource XML file locatied inside “<DOMAIN_HOME>\config\jdbc” directoryor may be the TNS name OR some n/w issue between WLS BOX and the DB Box. Please try the following to Double Check it.
Step1). Add JDBC Driver also in the Classpath or Better run “. ./setWLSEnv.sh”
(NOTE: While running the above script please use two DOTs like mentioned above. The first DOT represents that set the Environment in the Current Shell and the second DOT (./) Slash represents that pick up the Script from the current Location. Both DOTs are separated by a single space. Once u run “. ./setWLSEnv.sh” after that try to echo the values of $CLASSPATH and $PATH to make sure that the env is set properly)
Step2). Use WLS dbping utility to test the Database Network Connectivity from the WebLogic Server Box:
Syntax:
java -classpath /bea103/wl_server103/server/lib/weblogic.jar utils.dbping ORACLE_THIN <dbUserName> <dbPasswoes> <dbURL>
Example:
java -classpath /bea103/wl_server103/server/lib/weblogic.jar utils.dbping ORACLE_THIN scott tiger databaseHostName:1521:P15215h
————————————————————————–
Common Jdbc Issues-2).
Many times we see that DataSource configured on WebLogic Server was running fine sometimes back and suddenly we start seeing the following Error:
Caused by: java.sql.SQLException: Io exception: Got minus one from a read call
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:420)
Degugging the root Cause of above Issue:
The error “Caused by: java.sql.SQLException: Io exception: Got minus one from a read call” clearly indicates the root cause of this issue. “We get the following error “Got minus one from a read call” if the Database goes under Maintenance…..or Database is in inconsistent State (Due to any reason like Database Maintenance or Database unmounting…etc ).
The above error ensures that there is Nothing Wrong from WebLogic Side …we need to contact the Database Administrator only.
Step1). Open the Server Log and check the timestamp of the first occurance of that Error in the Server log.
Step2). Confirm with the Database Administrator…. What was the activity happening on the Database side at that time (90% cases u will find that the Database might be under Maintenance that time)
——-Make Use of Appropriate Debug Flags:———
-Dweblogic.resourcepool.max_test_wait_secs=xx
Where xx is the amount of time, in seconds, WebLogic Server waits for connection test before considering the connection test failed. By default, a server instance is assigned a value of 10 seconds. This command line flag manages failures, such as a DBMS network failure, which can cause connection tests and applications to hang for extended periods of time (for example, 10 minutes). If the assigned time period expires, the server instance purges and disables the pool (closes all connections and blocks further reserve attempts) and re-enables the pool as soon as it is possible to reconnect.
You can use the following Debug Flags:
-Dweblogic.debug.DebugJDBCSQL=true
-Dweblogic.log.StdoutSeverity=Debug
Use the Following WLST Script to Enable the JDBC related Debug Flags
“ExampleDebugJdbc.py”
—————————————————————–
user=’weblogic’
password=’weblogic’
url=’t3://localhost:7001′
connect(user, password, url)
edit()
cd(‘Servers/TestServer/ServerDebug/TestServer’)
startEdit()
set(‘DebugJDBCSQL’,'true’)
save()
activate()
—————————————————————–
Common Jdbc Issues-3).
If you see that the Database is going into DataSource is moving to SUSPENDED/Disabled State….The first of all check the database connectivity. If the dfatabase connectivity is OK and WLS is able to establish the Connectivity with the database Successfully then Please try to use the “weblogic.Admin” utility to Restore (Resume) the DataSource.
You can use “weblogic.Admin” utility to Enable and Disable the Pool (DataSource) Just to Confirm whether the dataSource is actually active or not:
Step1). run “. ./setWLSEnv.sh” first in the same Shell prompt….then do the following:
Step2). To suspend:
java weblogic.Admin -url t3://localhost:7001 -username weblogic -password weblogic SUSPEND_POOL YourDataSourceName
Step3). To re-enable:
java weblogic.Admin -url t3://localhost:7001 -username weblogic -password weblogic RESUME_POOL YourDataSourceName
To test whether you are getting any Exception or Error while doing this….If yes u are getting any Error or exception then It means there May be some Database connectivity issue…
If a datasource gets destroyed then even if u are having DataSource Configuration Entries in the “config.xml” and the “<DOMAIN_HOME>/config/jdbc/*.xml” files …still u wont be able to see that datasource in the Monitoring Tab in the AdminConsole. Because as soon as the datasource gets destroyed (Due to N/W disconnect or someother reason) the MBean Object gets destroyed.
Common Jdbc Issues-4).
<Warning> <JDBC> <BEA-001153> <Forcibly releasing inactive connection
“weblogic.jdbc.wrapper.PoolConnection_oracle_jdbc_driver_T4CConnection@3″ back into the connection pool “TestDataSource”, currently reserved by: java.lang.Exception
at weblogic.jdbc.common.internal.ConnectionEnv.setup(ConnectionEnv.java:291)
at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:314)
at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:292)
at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:425)
at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:316)
If we see above kind of exceptions in our Server Logs then definately we need to look into the Application Code. Usually we see this Warning When the Application code obtains a JDBC connection from the WLS datasource, then not using it and not closing it, Means Just Holding the Connection Reference, for longer than your datasource/pool is configured to allow (IdleConnectionTimeout). Make sure that u close all the JDBC related Objects in a proper sequence. like exactly in the following Order…Always close the ResultSet, Statement and Connection objects insode the finally{} Block in the following order:
finally {
try {resultset.close();}
catch (Exception rse) {}
try {statement.close();}
catch (Exception sse) {}
try {connection.close();
catch (Exception cse) {}
}
.
.
Thanks
Jay SenSharma
July 22nd, 2010 on 6:05 pm
Hello Jay, thanx for sharing this… i would ask something about JDBC and DS…
I made a DS connection in my WLS 10.0 MP2 to connect to a racle 8 DB and:
1) when i use this BEA’s Oracle Driver (Type 4 XA) Versions: 9.0.1,9.2.0,10. I have this error testing connection:
Connection test failed.
[BEA][Oracle JDBC Driver][Oracle]ORA-00604: error occurred at recursive SQL level 1 ORA-06502: PL/SQL: numeric or value error: character string buffer too small ORA-06512: at line 7
weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
weblogic.jdbc.base.BaseExceptions.getException(Unknown Source)
weblogic.jdbc.oracle.OracleImplConnection.connectAndAuthenticate(Unknown Source)
weblogic.jdbc.oracle.OracleImplConnection.open(Unknown Source)
weblogic.jdbc.base.BaseConnection.connect(Unknown Source)
weblogic.jdbc.base.BaseConnection.setupImplConnection(Unknown Source)
weblogic.jdbc.base.BaseConnection.open(Unknown Source)
weblogic.jdbcx.base.BaseXADataSource.getBaseConnectionPreparedForXA(Unknown Source)
weblogic.jdbcx.base.BaseXADataSource.getXAConnection(Unknown Source)
com.bea.console.utils.jdbc.JDBCUtils.testConnection(JDBCUtils.java:550)
com.bea.console.actions.jdbc.datasources.createjdbcdatasource.CreateJDBCDataSource.testConnectionConfiguration(CreateJDBCDataSource.java:438)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.apache.beehive.netui.pageflow.FlowController.invokeActionMethod(FlowController.java:870)
org.apache.beehive.netui.pageflow.FlowController.getActionMethodForward(FlowController.java:809)
org.apache.beehive.netui.pageflow.FlowController.internalExecute(FlowController.java:478)
org.apache.beehive.netui.pageflow.PageFlowController.internalExecute(PageFlowController.java:306)
org.apache.beehive.netui.pageflow.FlowController.execute(FlowController.java:336)
2) when i use this Oracle’s Driver (Thin XA) Versions: 9.0.1,9.2.0,10. I test the connection and its OK selecting cluster as targets, but when i have to Activate Changes i get this error:
An error occurred during activation of changes, please see the log for details.
weblogic.application.ModuleException:
ORA-00604: error occurred at recursive SQL level 1 ORA-12705: invalid or unknown NLS parameter value specified
Also appears a msg in the Change and Restarts tab:
You currently have a mix of changes, some requiring restart, others do not. The changes that do not require restart will not take effect until the restarts are completed.
Jay, can u help me with this issue please?
Thanx in advance
July 22nd, 2010 on 8:55 pm
Hi Mgaldames,
One Good Thing about both the Errors u are getting is….”WebLogic is not causing this issue, Rather The Oracle Database configurations are causing these issues”.
Regarding Issue-1). [BEA][Oracle JDBC Driver][Oracle]ORA-00604: error occurred at recursive SQL level 1 ORA-06502: PL/SQL:
This error ORA-00604 is actually coming from the Oracle Database side… PL/SQL Scripts are causing this issue.
Please refer to http://www.techonthenet.com/oracle/errors/ora06512.php
Regarding Issue-2). ORA-00604: error occurred at recursive SQL level 1 ORA-12705: invalid or unknown NLS parameter value specified
You need to ask your Database administratot to set the following AddVMOption : “-Duser.region” Option inside the “sqldeveloper.conf” file. Then u need to reboot the Database.
Example: -Duser.region=es
.
.
Keep Posting
Thanks
Jay SenSharma
July 23rd, 2010 on 9:21 am
Jay thanx for reply, i will talk with the DBA in charge about this…
I was thinking before that the problem refer to WLS configuration because when i use a local WLS 10.0 MP2 (i.e. from my macbook) i can made the DataSource to the Oracle 8. The error i showed u before appears in the WLS 10.2 in the Development environment server.
It’s weird that connect to to DS works for me (local WLS) but not in the development environment (errors shows u before).
Ok, thanx again for ur help Jay
August 4th, 2010 on 12:43 am
Hi Jay
we created a new Data source
but on monitoring tab or control tab
we are unable to see it…
where as on summary it is showing up
on bpel side the dbadapter is giving error…
How to make the datasource appear for testing….
pls help
sri
August 4th, 2010 on 11:52 am
Hi SVaidya,
If you are not able to see the dataSource in the AdminConsole DataSource Monitoring tab …it means the dataSource is Disabled (Destroyed)…. there may be many reasons behind this. The Best thing will be to look at the Server Log to find the root cause “Why the Pool got Destroyed….?”
Please refer to : http://forums.oracle.com/forums/thread.jspa?messageID=4387069 to see some Debugging issues …in this kind of scenarios.
.
.
Keep Posting
Thanks
Jay SenSharma
August 19th, 2010 on 8:05 pm
Hello Jay,
I see the below error in the logs :-
This error was there in the logs for long time, however
this time, i had to restart the server to solve this:-
Do you have any idea on this.
#### <>
#### <>
#### <>
#### <>
#### <> <Disable and freeze users called on connection pool "AR Data Source2-11G" by "”.>
#### <> <Exception in try: java.sql.SQLException: Unexpected exception while enlisting XAConnection java.sql.SQLException: XA error: XAResource.XAER_RMERR start() failed on resource 'weblogic.jdbc.jta.DataSource': XAER_RMERR : A resource manager error has occured in the transaction branch
javax.transaction.xa.XAException: Unexpected error during start for XAResource 'AR Data Source-11G': null
at weblogic.jdbc.wrapper.XA.createException(XA.java:103)
at weblogic.jdbc.jta.DataSource.start(DataSource.java:751)
at weblogic.transaction.internal.XAServerResourceInfo.start(XAServerResourceInfo.java:1183)
at weblogic.transaction.internal.XAServerResourceInfo.xaStart(XAServerResourceInfo.java:1116)
at weblogic.transaction.internal.XAServerResourceInfo.enlist(XAServerResourceInfo.java:275)
at weblogic.transaction.internal.ServerTransactionImpl.enlistResource(ServerTransactionImpl.java:508)
at weblogic.transaction.internal.ServerTransactionImpl.enlistResource(ServerTransactionImpl.java:435)
at weblogic.jdbc.jta.DataSource.enlist(DataSource.java:1407)
#### <> <EJB Exception occurred during invocation from home: org.sagph.iwr.domain.IwrDnLoginReg_sauw0g_HomeImpl@2dd7264 threw exception: java.rmi.RemoteException: EJB Exception:; nested exception is:
java.rmi.RemoteException: Unexpected exception while enlisting XAConnection java.sql.SQLException: XA error: XAResource.XAER_RMERR start() failed on resource 'weblogic.jdbc.jta.DataSource': XAER_RMERR : A resource manager error has occured in the transaction branch
javax.transaction.xa.XAException: Unexpected error during start for XAResource 'AR Data Source-11G': null
at weblogic.jdbc.wrapper.XA.createException(XA.java:103)
August 19th, 2010 on 8:26 pm
Hi Kamals,
It looks like you are using WLS8.1 …Please correct if i m wrong.
Usually this happens When we use combination of XA and Non-XA DataSources as part of a Single Transaction. Please make sure that either u use Both the DataSources as XA DataSource or Both the DataSources as Non-XA DataSource.
A non-XA driver does not adhere to the XA/2PC contracts and only supports one-phase commit and rollback operations, WebLogic Server (through the JTS driver) has to make compromises to allow the resource to participate in a transaction controlled by the Transaction Manager. You can try to Enable “Supports Global Transactions” for the non-XA connections from the data source to participate in global transactions.
Still i will suggest you to use Similar DataSources (either both XA or Both Non-XA) …as part of Single Tx to avoid this kind of scenarios.
NOTE: Emulate Two-Phase Commit option should only be used in applications that can tolerate heuristic conditions. Link : http://e-docs.bea.com/wls/docs81/ConsoleHelp/jdbc_datasources.html
.
.
Keep Posting
Thanks
Jay SenSharma
August 27th, 2010 on 5:40 pm
Though this error ‘XAResource.XAER_RMERR start() failed on resource’ is seen on all Managed server (4 servers) logs
However only one server ‘Q15′ it is occuring to an extent, where the application stops responding on this server, till it is restarted.
What bothers me is that if the issue is with application are database all the server inthe cluster should have probelm
Not sure why this happens only one managed server on weblogic?
Can you please help?
September 4th, 2010 on 3:06 am
Hi Jay,
I am migrating a legacy J2EE application to WebLogic and I am encountering Common JDBC Issue number 4. The application uses Oracle TopLink for the ORM and there are no references to ResultSet, Statement, or Connection. I thought that by verifying that UnitOfWork.release was called for every UnitOfWork, the issue would go away. However, the problem persists. Do you know how I might track down connection pool leaks in a TopLink application?
Thanks,
Carlos
September 4th, 2010 on 4:59 pm
Hi Carlos,
Not sure whether the “UnitOfWork.release()” will work in your case or not because it is not supported for External Transaction Control…Not sure which kind of transactions are participating in your Application.
But if we will look into the Complete StackTrace then definately we will be able to find it out …that the TopLink APIs are causing some issue or not?
Can u please post your Complete Stack Trace here…
NOTE: Please make sure that while pasting the Stack Trace in your comment you replace all the
< Characters with <
and
> Characters with >
Because in our website the contents placed inside < > are not visible. So i wont be able to see your stack trace …if you will paste that without replacing these special characters.
.
.
Keep Posting
Thanks
Jay SenSharma