1 Reply Latest reply on Oct 10, 2001 5:38 PM by marc fleury

    Oracle CLOBS - java.lang.NoClassDefFoundError for intf, not

    David Martinez Newbie

      Hello,

      This message pertains to JBoss-2.2.1

      I am writing a standalone EAR with some BMP entity beans. I am trying to read the CLOBs from within this EAR file by retrieving the actual OracleResultSet from the Minerva pool and casting it to OracleResultSet, like so:


      // Get l_connection from a DataSource through JNDI...
      l_statement = l_connection.prepareStatement(SELECT_ALL_BY_ID_QUERY);
      l_statement.setInt(1, p_Key.id);
      l_resultSet = l_statement.executeQuery();
      if (l_resultSet.next()) {
      // read some fields...

      // Now we need to read a CLOB
      ResultSet rs = (ResultSet)((org.opentools.minerva.jdbc.ResultSetInPool)l_resultSet).getUnderlyingResultSet();
      System.out.println("Casting ORS from "+rs);
      OracleResultSet oRS =(OracleResultSet)rs;
      System.out.println("Casted ORS");
      String clobResult = null;
      CLOB c =oRS.getCLOB(COL_EMAIL_XML);
      System.out.println("Got CLOB");
      if (c!=null) {
      System.out.println("Reading CLOB");
      Reader l_clobStream = c.getCharacterStream();
      StringBuffer l_big = new StringBuffer();
      // Read from the CLOB stream and write to the stringbuffer
      int l_nchars = 0; // Number of chanracters read
      char[] l_buffer = new char[10]; // Buffer holding characters being transferred
      while ((l_nchars = l_clobStream.read(l_buffer)) != -1) { // Read from CLOB
      l_big.append(l_buffer,0,l_nchars); // Write to StringBuffer
      }
      l_clobStream.close(); // Close the CLOB input stream
      clobResult = l_big.toString();
      }



      The problem is that, when I try to cast the object I get the following:

      [entity/SampleCLOBEntity] Casting ORS from oracle.jdbc.driver.OracleResultSetImpl@75b4d1
      [entity/SampleCLOBEntity] java.lang.NoClassDefFoundError: oracle/jdbc/OracleResultSet
      [entity/SampleCLOBEntity] at myEJB.ejbLoad(EMailTemplateEntityE
      JB.java:143)
      [entity/SampleCLOBEntity] at java.lang.reflect.Method.invoke(Native Method)
      [entity/SampleCLOBEntity] at org.jboss.ejb.plugins.BMPPersistenceManager.loadEntity(BMPPersistenceManager.java:299
      )
      [entity/SampleCLOBEntity] at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationIn
      terceptor.java:192)
      [entity/SampleCLOBEntity] at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java
      :186)
      ....


      I fixed this by changing the Cast to read as follows:


      oracle.jdbc.driver.OracleResultSetImpl oRS =(oracle.jdbc.driver.OracleResultSetImpl)rs;


      I would still like to know why though...

      Incidentally, we have a WebApp in a WAR that is doing just that by getting the connection through JNDI then casting the resultSet to the OracleResultSet interface. That one works. But when you place the same code in an EAR, it doesn't unless you use the actual implementation.

      Any Ideas?

      Thanks,