ClassCastException: com.sun.gjc.spi.ConnectionHolder for ArrayDescriptor.cr

Hi,

I'm running Sun Java System Application 8.1 and get ClassCastException on connection when create ArrayDescriptor.createDescriptor(arrayTypeName, conn );

ConnectionPool setup:

Datasource Classname: oracle.jdbc.pool.OracleDataSource

Resource Type: javax.sql.DataSource

Exception:

java.lang.ClassCastException: com.sun.gjc.spi.ConnectionHolder

oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:108)

com.rogers.cableit.ecid.bean.SubDeviceBean.editDevice(SubDeviceBean.java:295)

sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25)

java.lang.reflect.Method.invoke(Method.java:585)

com.devsphere.articles.calltag.MethodCaller.call(MethodCaller.java:57)

com.devsphere.articles.calltag.CallTag.doTag(CallTag.java:73)

org.apache.jsp.editdevice_jsp._jspx_meth_ctag_call_0(editdevice_jsp.java:304)

org.apache.jsp.editdevice_jsp._jspService(editdevice_jsp.java:185)

org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:105)

javax.servlet.http.HttpServlet.service(HttpServlet.java:860)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:336)

Any suggestions to work around?

Thanks,

Alexander

[1445 byte] By [apant] at [2007-11-26 8:25:48]
# 1

I am not sure what oracle.sql.ArrayDescriptor.createDescriptor internally does. (It takes a Connection object).

It tries to cast the connection to its own implementation.

In Connection pool environment, wrapped connection objects are returned to the application and application server's conn pool framework will internally manage the actual connections. Actual connection are not given to application explicitly.

To solve the problem, you can get the actual Oracle connection and pass it to ArrayDescriptor.

eg code snippet:

InitialContext ctx = new InitialContext();

DataSource ds = ctx.lookup("jdbc/datasource");

Connection conn = ds.getConnection();

OracleConnection oconn=(OracleConnection)ds.getConnection(conn);

//use this oconn for ArrayDescriptor.

//Caution: Even though the actual physical connection is got by the application, //application should not close it.

//While closing the connection,

oconn = null; // Just remove the reference (Donot use oconn.close())

conn.close(); // This will return the connection back to the pool

Hope this helps.

Thanks,

-Jagadish

JagadishPrasath at 2007-7-6 21:39:15 > top of Java-index,Application & Integration Servers,Application Servers...
# 2
Thank you a lot.com.sun.appserv.jdbc.DataSource.getConnection(conn) can be casted to the OracleConnection . It seems as it's a physical connection and should not be closed.Thanks,Alexander
apant at 2007-7-6 21:39:15 > top of Java-index,Application & Integration Servers,Application Servers...