Link to home
Start Free TrialLog in
Avatar of todd_farmer
todd_farmerFlag for United States of America

asked on

java.sql.SQLException: Io exception: Protocol violation in Jrun4 with Oracle10g

Hi,

I'm having difficulty with this error.  The stack trace is below:
 com.mycompany.exception.DomainException: java.sql.SQLException: Io exception: Protocol violation
      at com.mycompany.database.DAO.implementation.UserDbDAO.getUsersByCriteria(UserDbDAO.java:400)
      at com.mycompany.web.struts.action.UserSearchAction.execute(UserSearchAction.java:56)
      at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
      at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
      at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
      at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
      at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:252)
      at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
      at jrun.servlet.http.WebService.invokeRunnable(WebService.java:168)
      at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:451)
      at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
Caused by: java.sql.SQLException: Io exception: Protocol violation
      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:170)
      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:212)
      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:325)
      at oracle.jdbc.driver.OracleStatement.prepare_for_new_result(OracleStatement.java:2606)
      at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:402)
      at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:344)
      at jrun.sql.JRunPreparedStatement.executeQuery(JRunPreparedStatement.java:69)
      at com.mycompany.database.DAO.implementation.UserDbDAO.getUsersByCriteria(UserDbDAO.java:294)
      ... 14 more
 

 javax.servlet.ServletException: java.sql.SQLException: Io exception: Protocol violation
      at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
      at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
      at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
      at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
      at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
      at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:252)
      at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
      at jrun.servlet.http.WebService.invokeRunnable(WebService.java:168)
      at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:451)
      at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
 

The error indicates a problem within the com.mycompany.database.DAO.implementation.UserDbDAO.getUsersByCriteria() method.  The line referenced is:

            rs = ps.executeQuery();

The ps variable is a PreparedStatement that is set earlier.  I have test cases that execute outside of my AS (JRun4), and they consistently return correctly.  The problem appears only when I run the search through the web application - using the same exact parameters as my test case.  Both are consistent - test case consistently works, JRun consistently fails.

The database table that is being searched resides on an Oracle 10g database, and contains a column defined as a LONG data type.  I initially thought that this might be the cause of the problem, but found that I don't have issues with other methods that return the same exact columns using different criteria.

I've checked various resources online, and have not found a solution.  Any ideas?

SOLUTION
Avatar of mrigank
mrigank

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mrigank
mrigank

Add it (classes12.zip) to your classpath in front of all other jars, even the JRun jars.
Avatar of todd_farmer

ASKER

I am using the same version of classes12.zip for both my unit testing and in the JRun4\server\lib directory.  There is no ojdbc.jar file in either.

I'm not so sure how I would modify the classpath that is used by JRun - are you suggesting thatJRun uses the Windows CLASSPATH environment variable?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
classes*.jar is generally used with jdk1.2 and 1.3. which version of java u r using? if 1.4 and above use ojdbc14.jar
http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc101040.html
Thanks, I'll give ojdbc14.jar a shot and report back.
I'm still having difficulty, but it's a bit different now (or I missed it previously).  I now get the following stack trace:

 com.mycompany.exception.DomainException: java.sql.SQLException: Io exception: Bigger type length than Maximum
      at com.mycompany.database.DAO.implementation.UserDbDAO.getUsersByCriteria(UserDbDAO.java:496)
      at com.mycompany.web.struts.action.UserSearchAction.execute(UserSearchAction.java:56)
      at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
      at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
      at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
      at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
      at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:252)
      at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
      at jrun.servlet.http.WebService.invokeRunnable(WebService.java:168)
      at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:451)
      at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
Caused by: java.sql.SQLException: Io exception: Bigger type length than Maximum
      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:334)
      at oracle.jdbc.driver.OracleStatement.prepare_for_new_get(OracleStatement.java:3395)
      at oracle.jdbc.driver.OracleStatement.getStringValue(OracleStatement.java:3615)
      at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:460)
      at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1543)
      at com.mycompany.database.DAO.implementation.UserDbDAO.getUsersByCriteria(UserDbDAO.java:299)
      ... 14 more
 

 javax.servlet.ServletException: java.sql.SQLException: Io exception: Bigger type length than Maximum
      at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
      at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
      at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
      at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
      at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
      at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:252)
      at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
      at jrun.servlet.http.WebService.invokeRunnable(WebService.java:168)
      at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:451)
      at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
 
The error indicates the root cause is the following line:

                rs.getString("commentsview");

The commentsview column is defined as a VARCHAR2(1) (yeah, I know - I didn't write that junk).  It has values of "Y", "N" and null in the database currently.

When I do a page reload after this initial error, I get the Protocol error:

 com.mycompany.exception.DomainException: java.sql.SQLException: Protocol violation
      at com.mycompany.database.DAO.implementation.UserDbDAO.getUsersByCriteria(UserDbDAO.java:496)
      at com.mycompany.web.struts.action.UserSearchAction.execute(UserSearchAction.java:56)
      at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
      at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
      at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
      at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
      at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:252)
      at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
      at jrun.servlet.http.WebService.invokeRunnable(WebService.java:168)
      at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:451)
      at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
Caused by: java.sql.SQLException: Protocol violation
      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
      at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:1160)
      at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:594)
      at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1986)
      at oracle.jdbc.ttc7.TTC7Protocol.executeFetch(TTC7Protocol.java:1005)
      at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2687)
      at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2850)
      at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:609)
      at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:537)
      at jrun.sql.JRunPreparedStatement.executeQuery(JRunPreparedStatement.java:69)
      at com.mycompany.database.DAO.implementation.UserDbDAO.getUsersByCriteria(UserDbDAO.java:294)
      ... 14 more
 

 javax.servlet.ServletException: java.sql.SQLException: Protocol violation
      at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
      at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
      at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
      at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
      at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
      at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:252)
      at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
      at jrun.servlet.http.WebService.invokeRunnable(WebService.java:168)
      at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:451)
      at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
 
My best guess is that there is something with how I'm using the Connection object that is causing that problem, but I'm not sure.  Here's the skeleton of my code (I pulled out all the ps.setString() and rs.getString() methods, or the post would be too large:

   public List getUsersByCriteria(String lastname, String firstname,
            String custid, String status, String associatedEntityCode,
            String associatedEntityBranch, String associatedEntityType)
            throws DomainException {
        List l = new ArrayList();
        Connection conn = null;
        ResultSet rs = null;
        PreparedStatement ps = null;
        try {
            conn = ds.getConnection();
            ps = conn.prepareStatement(sql.toString());
   
... setting prepared statement parameters here ...  

            rs = ps.executeQuery();
            while (rs.next()) {

                User u = new User(
                        rs.getString("address1"),
... bunch of rs.getString()s here ...
                       
                        );
                l.add(u);
            }
            return l;
        } catch (SQLException e) {
            LOG.error(e);
            throw new DomainException(e);
        } finally {
            ConnectionManager.closeResultSet(rs);
            ConnectionManager.closeStatement(ps);
            ConnectionManager.closeConnection(conn);
        }

    }
It does appear to be the LONG column that causes this issue, even though I don't read it from the ResultSet.  When I changed the query to return explicit column names ("SELECT username, firstname, lastname, ...") instead of all columns, the problem went away.