2 Replies Latest reply on Feb 5, 2007 10:44 AM by Richard De los Reyes

    ArrayDescriptor creation throws ClassCastException in JBoss

    Jason Sam Newbie

      Hi all,

      I am trying to save and retrieve array of Java objects in Oracle (9i) database. I am successful in reading and writing user defined objects. But when I try to store array of such objects and following the recommendation by Oracle to use the ArrayDescriptor and create a descriptor for the user defined array type, JBoss throws the following exception (not the complete list).
      There was a previous post of this forum (http://www.jboss.org/index.html?module=bb&op=viewtopic&t=13961) and unfortunately the pointed out link in the response is invalid. So please if you have come across this problem and know of the solution pelase let me know.


      My connection url is:
      My driver is:

      java.lang.ClassCastException: org.jboss.resource.adapter.jdbc.WrappedConnection
      at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:108)
      at testbean.WelcomeBean.greetings(WelcomeBean.java:96)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:582)
      at org.jboss.invocation.Invocation.performCall(Invocation.java:345)

        • 1. Re: ArrayDescriptor creation throws ClassCastException in JB
          rokendo Newbie


          I've come across the same issue when trying to create a Oracle User Defined Array via the ArrayDescriptor. The issue is that the Connection object returned by Jboss is a WrappedConnection.

          One possible way to resolve the issue is by doing something like the following:
          WrappedConnection.getUnderlyingConnection() . This will require importing (include jboss-common-jdbc-wrapper.jar with WrappedConnection class).

          A better way, which I'm looking for, is to somehow configure jboss to give me an OracleConnectionPool directly like it does in tomcat by configuring the server.xml like so:

          Tomcat 5.5

          name="jdbc/my_jndi_name" auth="Container" type="oracle.jdbc.pool.OracleDataSource" factory="oracle.jdbc.pool.OracleDataSourceFactory"
          maxActive="20" maxIdle="10" maxWait="10000"
          url="jdbc:oracle:thin:@my_db_url:1521:my_db" user="user" password="pw" connectionCachingEnabled="true"

          Does anybody know how to configure Jboss to expliclty return an OracleDataSource? I've looked over all the jboss documentation and don't see any attribute to do something similar to the fix above for Tomcat?

          Thanks in advance,

          • 2. Re: ArrayDescriptor creation throws ClassCastException in JB
            Richard De los Reyes Newbie


            I had the same problem in the last week, and found the solution,
            The ArrayDescriptor and ARRAY needed a Native Connection, and the mode to get this is:

            cstmt = (OracleCallableStatement) getSession().connection().prepareCall(" call REP_UPDATE_STOCK_WAREHOUSE(?, ?, ?, ?, ?) ");

            ArrayDescriptor descCE = ArrayDescriptor.createDescriptor("NUMBER_NT", cstmt.getConnection());

            A OracleCallableStatement.getConnection returns a Native Connection... use that for parameter the ArrayDescriptor.createDescriptor and the ClassCastException will solve.