Java Stored Procedure, Reflection across Schemas [message #415697] |
Tue, 28 July 2009 15:26 |
mike__porter@hotmail.com
Messages: 3 Registered: July 2009
|
Junior Member |
|
|
I've got 2 jars deployed on 2 separate schemas on the same Oracle database.
One of the classes on one schema uses reflection to create an object from a class on the other schema. I've worked through most of it with the classForNameAndSchema(), but getting a class cast exception when trying to cast the object to its type.
Here's the code
Class cls;
Schema s = Schema.lookup("XYZ");
cls = DbmsJava.classForNameAndSchema("mypack.Unbeleivable", s);
// no arg constructor
Constructor ct = cls.getConstructor(null);
Object o = ct.newInstance(null);
System.out.println("Class type is " + o.getClass().getName());
Unbeleivable ub = (Unbeleivable) o;
The class cast exception is on the last line; the systemout would be displaying
Class type is mypack.Unbeleivable
At the moment, I have the Unbeleivable class (a .class file, not a .java) included in the 2 jars.
How do you get the ClassCastException resolved?
Also - what jar is the DBMSJava classes in?
thanks
Mike
|
|
|
|
Re: Java Stored Procedure, Reflection across Schemas [message #415794 is a reply to message #415730] |
Wed, 29 July 2009 06:02 |
mike__porter@hotmail.com
Messages: 3 Registered: July 2009
|
Junior Member |
|
|
It is. Didn't do an import, but explicitly defined and casting it like so
mypack.Unbeleivable ub = (mypack.Unbeleivable) o;
What I've done is put this Unbeleivable class into both of the jars, so it exists on either side. I think what I have right now is including the .java files, which would get compiled during the loadjava step. I think this way, these two classes, although named the same, are different, causing the castexception. I'll just put the class in on one the jars, and see if I can resolve it that way.
Would anyone know what jar any of these imports are from?
import oracle.aurora.rdbms.ClassHandle;
import oracle.aurora.rdbms.Schema;
import oracle.aurora.rdbms.DbmsJava;
I'm essentially coding the java without those jars, and having them resolve during the loadjava step. I've searched through my oracle jars, and can't locate them
|
|
|
|
|