Hi
I am using weblog.jar file as suggested by somebody in a forum,
Can somebody tell me why I am getting Class Cast Error on RUNTIME? I am able to
compile the code.
SerialOracleBlob cast1 =(SerialOracleBlob)result.getTheRealBlob("FILE_IMAGE"); //
ERROR IS COMING on runtime
OracleTBlobImpl cast2 =(OracleTBlobImpl)cast1.getTheRealBlob();
myBlob = (oracle.sql.BLOB)cast2.getTheRealBlob();
ERROR:
java.lang.ClassCastException
at
com.mot.iDEN.webapp.oes.servlet.FileDisplayServlet.readBlob(FileDisplayServlet.java:174)
at
com.mot.iDEN.webapp.oes.servlet.FileDisplayServlet.action(FileDisplayServlet.java:90)
SerialOracleBlob.java is attached.
Best Regards
Abhay Kumar
-----Original Message-----
From: Robert Hall [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 06, 2004 7:06 PM
To: Tomcat Users List
Subject: Re: [OT] getBlob() error in Tomcat
Hi,
You can determine the actual Class of 'result' by doing:
String className = result.getClass().getName();
HTH,
Robert
Kumar Abhay-CAK203C wrote:
>Still not working
>
>I am using
>myBlob = ((OracleResultSet)result).getBLOB(1);
>
>It is giving Class Cast Exception
>
>Best Regards
>Abhay Kumar
>
>-----Original Message-----
>From: Summers, Bert W. [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, April 06, 2004 2:35 PM
>To: Tomcat Users List
>Subject: RE: [OT] getBlob() error in Tomcat
>
>
>Unjar the classes12.jar file and look for it.
>There should be some xxxxResultSet class in there.
>
>The jdbc class that come with Java do not implement the getBLOB method,
>hence the abstract violation. The Oracle driver in the case has the
>implemented method, of course you are now tied to Oracle in your code.
>
>-----Original Message-----
>From: Kumar Abhay-CAK203C [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, April 06, 2004 12:15 PM
>To: 'Tomcat Users List'
>Subject: RE: [OT] getBlob() error in Tomcat
>Importance: High
>
>
>Thanks for the suggestions,
>
>My question is how I can check that both the versions are same, I have
>classes12.jar in common/lib and that is set in system classpath.
>How to find the OracleResultSEt class to cast result?
>
>Best Regards
>Abhay Kumar
>
>-----Original Message-----
>From: Mike Curwen [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, April 06, 2004 1:59 PM
>To: 'Tomcat Users List'
>Subject: RE: [OT] getBlob() error in Tomcat
>
>
>The javadoc for that error suggests:
>"this error can only occur at run time if the definition of some class
>has incompatibly changed since the currently executing method was last compiled."
>
>So is the version of classes12.jar that you used to compile the code,
>the exact same version that is being used to run it ?
>
>As for casting......
>
>OracleResultSetClass foo = (OracleResultSetClass)result;
>
>obviously, you'd need to replace 'OracleResultSetClass' with the actual
>name of the class.
>
>
>
>
>>-----Original Message-----
>>From: Kumar Abhay-CAK203C [mailto:[EMAIL PROTECTED]
>>Sent: Tuesday, April 06, 2004 1:43 PM
>>To: 'Tomcat Users List'
>>Subject: RE: [OT] getBlob() error in Tomcat
>>Importance: High
>>
>>
>>I will appreciate you if you can tell me how ?
>>
>>Best Regards
>>Abhay Kumar
>>
>>-----Original Message-----
>>From: Summers, Bert W. [mailto:[EMAIL PROTECTED]
>>Sent: Tuesday, April 06, 2004 1:05 PM
>>To: Tomcat Users List
>>Subject: RE: [OT] getBlob() error in Tomcat
>>
>>
>>You need to cast the ResultSet to the Oracle specify ResultSet
>>
>>-----Original Message-----
>>From: Kumar Abhay-CAK203C [mailto:[EMAIL PROTECTED]
>>Sent: Tuesday, April 06, 2004 11:01 AM
>>To: Tomcat Users List
>>Subject: [OT] getBlob() error in Tomcat
>>Importance: High
>>
>>
>>Hi,
>>
>>Any idea why this error is coming in runtime?
>>
>>Servlet) - FileDisplayServlet.doPost()
>>java.lang.AbstractMethodError:
>>oracle.jdbc.driver.OracleResultSetImpl.getBlob(Ljava/lang/Stri
>>ng;)Ljava/sql/
>>Blob;
>> at
>>org.apache.commons.dbcp.DelegatingResultSet.getBlob(Delegating
>>ResultSet.java
>>:318)
>> at
>>com.mot.iDEN.webapp.oes.servlet.FileDisplayServlet.readBlob(Fi
>>leDisplayServl
>>et.java:169)
>>
>>I am trying to display a image that is stored in a BLOB field in
>>Oracle. I am using connection pooling and classes12.jar
>>
>>Servlet Code
>>--------------------------------------------------------------
>>--------------
>>--------------------------------------------------------------
>>--------------
>>--------
>> private void readBlob
>> (
>> HttpServletRequest request,
>> HttpServletResponse response,
>> long aFeatureId,
>> String aFileName,
>> String aUserId
>> )
>> throws SQLException,IOException
>> {
>> Connection conn = null;
>> ResultSet result = null;
>> PreparedStatement prepStmt = null;
>> java.io.InputStream in = null;
>> java.sql.Blob myBlob = null;
>> FileUploadFactory uploadFactory = new
>>FileUploadFactory();
>>
>> try
>> {
>> conn = config_.getEstimationConnection(false);
>> String sql = "";
>> sql =
>> " SELECT "+
>> " FILE_IMAGE "+
>> " FROM "+
>> " OES_FEATURE_DETAILS "+
>> " WHERE "+
>> " FEATURE_ID =
>>"+aFeatureId;
>>
>> log_.debug("SQL:==="+sql);
>> log_.debug("result=" + result);
>> prepStmt = conn.prepareStatement(sql);
>> result = prepStmt.executeQuery();
>> if (result != null && result.next())
>> {
>> //get the file ext
>> String strDocExt = "";
>> try
>> {
>> strDocExt =
>>uploadFactory.getFileType(aFileName, aUserId);
>> }
>> catch(Exception e)
>> {
>> log_.debug("Exception is"+e);
>> }
>> //get the file length
>> int intCountBytes = 0;
>> String strPrpValue = null;
>> //set the mimetype
>> ResourceBundle mimetype =
>>
>>
>ResourceBundle.getBundle("mimes");
>
>
>> strPrpValue =
>> mimetype.getString(strDocExt.toLowerCase());
>> log_.debug("Value=" + strPrpValue);
>> if (strPrpValue != null)
>> {
>>
>>response.setContentType(strPrpValue);
>>
>>response.setHeader("Content-Disposition", "inline; filename="
>>+ aFileName);
>> }
>> myBlob = result.getBlob("FILE_IMAGE");
>> //get the inputStream
>> in = myBlob.getBinaryStream();
>> /*Get the Output Stream*/
>> if (in != null)
>> {
>>
>>generatePresentation(in, response);
>> in.close();
>> }
>> }
>> }
>> catch (SQLException sqle)
>> {
>> throw new
>>SQLException("FileDisplayServlet.readBlob", "" + sqle.getErrorCode());
>> }
>> catch (IOException io)
>> {
>> throw new
>>IOException("FileDisplayServlet.readBlob");
>> }
>> finally
>> {
>> try
>> {
>> if (result != null)
>> {
>> result.close();
>> }
>> if (prepStmt != null)
>> {
>> prepStmt.close();
>> }
>> if (conn != null)
>> {
>> conn.close();
>> }
>> }
>> catch (SQLException sqle)
>> {
>> throw new
>>SQLException("FileDisplayServlet.readBlob");
>> }
>> }
>> }
>>--------------------------------------------------------------
>>--------------
>>--------------------------------------------------------------
>>--------------
>>----
>>
>>Best Regards
>>Abhay Kumar
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]