3 Replies Latest reply on Jan 22, 2016 9:30 PM by jaysensharma

    Exception while storing data in Oracle XMLType column

    jboss234

      Using Wildfly8.2.0,

      I am getting java.lang.ClassCastException: org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7 cannot be cast to org.jboss.resource.adapter.jdbc.WrappedConnection  --------- while storing data in Oracle's XMLType column,

       

      The below code was working fine with JBoss 4.0.3, after migrating application on Wildfly8.2.0 it started throwing above exceptions.

       

      org.jboss.resource.adapter.jdbc.WrappedConnection con = (org.jboss.resource.adapter.jdbc.WrappedConnection)dbConnection;    - throwing exception at this line

      XMLType xml = XMLType.createXML(con.getUnderlyingConnection(), dataAsInputStream);

       

      Any workaround ?

       

      Thanks,

        • 1. Re: Exception while storing data in Oracle XMLType column
          jaysensharma

          The same JBoss 4 based code will not run as it is in WildFly because some of the legacy classes are changed. Like "org.jboss.resource.adapter.jdbc.WrappedConnection"  class does not exist anymore in WildFly.

           

          So you should try something like following:

           

            java.sql.Connection conn = dataSource.getConnection(); 
          
            if (conn.isWrapperFor(OracleConnection.class)) { 
                 OracleConnection oracleConn = conn.unwrap(OracleConnection.class); 
                 XMLType xml = XMLType.createXML(oracleConn, dataAsInputStream); 
              ... 
            } else { 
              // Your own logic as the connection is not Oracle connection. 
            } 
          
          
          

           

           

          OR  as an alternate approach you may try.

           

          java.sql.Connection conn = dataSource.getConnection();  
          
          if (conn instanceof org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7) {
                org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7 wrappedConn = (org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7) conn;
                OracleConnection oracleConn = (OracleConnection) wrappedConn.getUnderlyingConnection();
                XMLType xml = XMLType.createXML(oracleConn, dataAsInputStream);     
          }
          

           

          Regards

          Jay SenSharma

          1 of 1 people found this helpful
          • 2. Re: Exception while storing data in Oracle XMLType column
            jboss234

            I am getting java.lang.ClassNotFoundException: org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7.

            Looks like WrappedConnectionJDK7 class is not visible to EJB jar file.

             

            Application structure,

             

            EAR

                 l

                 l---- WAR

                 l---- EJB JAR

             

            How to make the dependency JARs loaded by module visible to classes of EJB jar file within EAR.

             

            Thanks,

            • 3. Re: Exception while storing data in Oracle XMLType column
              jaysensharma

              You will need to add the "jboss-deployment-structure.xml" file something like following inside your "$EAR/META-INF" directory :

               

              <?xml version="1.0" encoding="UTF-8"?>

              <jboss-deployment-structure>

                   <deployment>

                       <dependencies>

                           <module name="org.jboss.ironjacamar.jdbcadapters" slot="main" export="true"/>

                           <module name="com.oracle" export="true" />

                       </dependencies>

                   </deployment>

              </jboss-deployment-structure>

               

               

              Regards

              Jay SenSharma

              1 of 1 people found this helpful