Monday Oct 14, 2013

Troubleshooting java.sql.SQLRecoverableException: IO Error: Invalid Packet Lenght

Some time ago, one of my customers had the following intermittent issue in WebLogic Server:

java.sql.SQLRecoverableException: IO Error: Invalid Packet Lenght
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:875)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1153)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1275)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3620)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)
at jdbc.JDBCTester.main(JDBCTester.java:31)
Caused by: oracle.net.ns.NetException: Invalid Packet Lenght
at oracle.net.ns.Packet.processHeader(Packet.java:372)
at oracle.net.ns.Packet.receive(Packet.java:304)
at oracle.net.ns.DataPacket.receive(DataPacket.java:104)

I tried enabling jdbc debugs but no clues on what was happening.

I decided to see if this was happening outside of WLS.

My customer tested using sqlplus but the issue was not occurring.

Then, I decided to check if the issue occurred with any Java application connected to the database.

My customer run my test program about 1000 times and then voila!, the issue was reproduced outside of WebLogic Server.

It turned out that there were network issues with this box that were fixed by customer's network team.

You can use these types of testers under similar issues you might experience to try to isolate the component/layer where the issue occurs.

Enjoy!

Here is my JDBC tester.


**************************************
JDBC Tester
**********************************************

i. Save the code below as TestJDBC.java
The successful case will print
finished DB testing

/********************************************/
package jdbc;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.DriverManager;
import javax.sql.DataSource;
class TestJDBC {
public static void main(String[] args) {
try {
String url = "jdbc:oracle:thin:@//localhost:1521/orcl";
Connection conn = DriverManager.getConnection(url, "javauser", "javauser");
PreparedStatement ps = null;
ResultSet rs = null;
String sid;
String sSQL = "select count(1) from dual";
try {
ps = conn.prepareStatement(sSQL);
rs = ps.executeQuery();

  
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
rs.close();
} catch (Exception rse) {
}
try {
ps.close();
} catch (Exception sse) {
}
try {
conn.close();
} catch (Exception cse) {
}
System.out.println("finished DB testing");
}

  
} catch (Exception e) {
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
}
}
}
/********************************************/
ii. mkdir jdbc
iii. mv TestJDBC.java jdbc
iv. cp WL_HOME/server/lib/ojdbc6.jar  jdbc
vi. Modify jdbc/TestJDBC.java according to your settings
                     String url = "jdbc:oracle:thin:@//localhost:1521/orcl";

Connection conn = DriverManager.getConnection(url, "javauser", "javauser");
vii. execute:
. ./setDomainEnv.sh (this file is locate at <domain>/bin folder. Notice the . before ./)
viii. CLASSPATH="${CLASSPATH}:.:/jdbc"
ix. export CLASSPATH
x. cd jdbc
xi. javac TestJDBC.java
xii. cd ..
xiii. java jdbc.TestJDBC

About


My name is Luz Mestre. I work as Principal Technical Support Engineer at Oracle Support. I'll post here the most interesting challenges I have in my daily work. The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

Search

Categories
Archives
« July 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today