Mantis - Resin
Viewing Issue Advanced Details
1310 major always 08-21-06 20:21 08-24-06 09:32
gzhu Linux or Solaris 10 x86 64bit  
ferg Debian (for e.g.)  
normal 2.6.7-1-686-smp  
closed 3.0.19  
built Mon, 15 May 2006 04:50:47 fixed  
none    
none 3.0.22  
0001310: create CMP ejb failed with "Missing IN or OUT parameter at index::.." when prepare statement cache size is greater than 0
Repeatedly creating CMP ejb will fail if the <prepare-statement-cache-size..> is greater than 0. This is happening with Oracle thin driver in ojdbc14.jar, connecting to Oracle 10.2.0 server.

Looks like unclean preparedStatement (with bind objects off) were returned from Connection.prepareStatement(sql), which caused the exceptions thrown at executeUpdate(). It only happens when you have a tight loop to get prepareStatement; a couple of seconds of delay would ease this problem.

A couple of days debugging showed that the culprit was not directly from com.caucho.amber.manager.AmberConnection::_prepareStatementMap.

======== stack trace from the attached test case ==============

com.caucho.ejb.CreateExceptionWrapper: java.sql.SQLException: Missing IN or OUT parameter at index:: 3
   at _ejb.TestEjb.TestEjbCMP__EJB$LocalHome.create(TestEjbCMP__EJB.java:324)
   at _jsp._jsp._test._testEJB__jsp._jspService(_testEJB__jsp.java:39)
   at com.caucho.jsp.JavaPage.service(JavaPage.java:60)
   ......
1. Create a CMP java:
=========== testejb/TestEjbBean.java ==========================
package testejb;

import java.util.*;
import javax.ejb.*;
import javax.naming.*;


/**
 *
 * @ejb.bean
 * name = "TestEjb"
 * local-jndi-name = "TestEjbHome"
 * cmp-version = "2.x"
 * reentrant = "False"
 * view-type = "local"
 * @ejb.persistence
 * table-name = "test_ejb"
 * @ejb.transaction
 * type = "Required"
 * @ejb.pk class = "testejb.TestEjbPK"
 * @version $Id$
 */
public abstract class TestEjbBean
        implements EntityBean
{

        /**
     * No argument constructor.
     * Sets up the environment based on values in the bean's ejb-jar.xml deployment descriptor file.
     * @ejb.create-method
     */
        public TestEjbPK ejbCreate () throws CreateException {
        setId(0);
            return new TestEjbPK(getId());
    }

        /**
     * No argument constructor.
     * Sets up the environment based on values in the bean's ejb-jar.xml deployment descriptor file.
     * @ejb.create-method
     */
        public TestEjbPK ejbCreate (int id, String name) throws CreateException {
        try {
                        ejbCreate();
            setId(id);
            setName(name);
        }
        catch (Exception e) {
            throw new CreateException("ERROR: Couldn't create testejb bean");
        }
            return new TestEjbPK(getId());
    }

        /**
         * @ejb.persistence
         * column-name = "id"
         * sql-type = "INTEGER"
         * jdbc-type = "INTEGER"
         * @ejb.pk-field
         * @ejb.interface-method
         */
        public abstract int getId();
        /**
         * @ejb.interface-method
         * @param _value
         */
        public abstract void setId(int _value);

        /**
         * @ejb.persistence
         * column-name = "name"
         * sql-type = "VARCHAR(15)"
         * jdbc-type = "VARCHAR"
         * @ejb.interface-method
         */
        public abstract String getName();
        /**
         * @ejb.interface-method
         * @param _value
         */
        public abstract void setName(String _value);
}
========== end of testejb/TestEjbBean.java ===============


2. a simple JSP to trigger the exception

============== my.jsp =====================
<%@
        page import="testejb.*, javax.naming.*, javax.ejb.*, java.io.*"
%>
<html>
<body>
<h1>EJB Creation Test</h1>
<%
Context context = new InitialContext();
TestEjbHome h = (TestEjbHome) (context.lookup("java:comp/env/cmp/TestEjb"));
try
{
        for (int i=1; i< 5; i++)
        {
            TestEjb t = h.create(i, "name"+i);
            out.println("Created TestEjb: ("+ t.getId() + ", " + t.getName()+&qu
ot;)\n\n");
            out.flush();
        }
}
catch(Exception ex)
{
    ex.printStackTrace(new PrintWriter(out));
}

%>

</body>
</html>
=============== end of my.jsp ===========



Notes
(0001479)
ferg   
08-24-06 09:32   
The prepared statement cache shouldn't be caching prepared statements with a result type.