jakarta-slide-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 37582] New: - Simple PUT document request results in exception on Oracle 9i
Date Mon, 21 Nov 2005 21:08:41 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37582>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=37582

           Summary: Simple PUT document request results in exception on
                    Oracle 9i
           Product: Slide
           Version: 2.1
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: Stores
        AssignedTo: slide-dev@jakarta.apache.org
        ReportedBy: cfitch@metatomix.com


Environment Details:
Linux 2.6 kernel(Suse 9.1)
JDK 1.4.2_06
Oracle 9.2 DB and JDBC Driver

Description:
Upon executing a PUT document request, I receive the following exception(with
relevant trace):

java.lang.IllegalArgumentException: object is not an instance of declaring class
        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:324)
        at
org.apache.slide.store.impl.rdbms.OracleRDBMSAdapter.storeContent(OracleRDBMSAdapter.java:142)


Digging around the problem results from an incorrect usage of java reflection to
execute a method.

Specifically:

In stores section, the class
org.apache.slide.store.impl.rdbms.OracleRDBMSAdapter declares the following
instance variable: 

    protected Method blobGetOutStreamMethod;


The constructor for the class is as follows:

    public OracleRDBMSAdapter(Service service, Logger logger) 
        throws ClassNotFoundException, NoSuchMethodException 
    {
        super(service, logger);
        
        Class bCls = Class.forName("oracle.sql.BLOB");
        blobGetOutStreamMethod = bCls.getMethod("getBinaryOutputStream", new
Class[] {});
    }

Later on, the Adapter attempts to retrieve the java.io.OutputStream for the Blob
by making this call:

    os = (OutputStream) blobGetOutStreamMethod.invoke(bObj, new Object[] {});


Though syntactically correct, this code results in the above exception.

In the constructor, the method is retrieved from a Class object and NOT an
instance of the Class itself.

According to the javadoc for the Method.invoke() call, invoke() will throw:

IllegalArgumentException - if the method is an instance method and the specified
object argument is not an instance of the class or interface declaring the
underlying method 

Since the method was retrieved from a Class object and not an instance, it's not
an Instance method. This is discussed on the Sun Java forums.

The correct code is as follows:

replace this line(line 142) 

    os = (OutputStream) blobGetOutStreamMethod.invoke(bObj, new Object[] {});

with the following two lines:

    Method blobGetOutputStreamMethod =
bObj.getClass().getMethod("getBinaryOutputStream",new Class[0]);
    os = (OutputStream) blobGetOutputStreamMethod.invoke(bObj, new Object[0]);

and remove the two lines in the constructor.

Thanks!

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org


Mime
View raw message