Home » Developer & Programmer » JDeveloper, Java & XML » Java Stored Procedure, Reflection across Schemas (Oracle 10g)
Java Stored Procedure, Reflection across Schemas [message #415697] Tue, 28 July 2009 15:26 Go to next message
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 #415730 is a reply to message #415697] Wed, 29 July 2009 01:08 Go to previous messageGo to next message
Frank
Messages: 7901
Registered: March 2000
Senior Member
Is the (unqualified) Unbeleivable the same as the mypack.Unbeleivable?
You did not show the imports, so we cannot tell.
Re: Java Stored Procedure, Reflection across Schemas [message #415794 is a reply to message #415730] Wed, 29 July 2009 06:02 Go to previous messageGo to next message
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
Re: Java Stored Procedure, Reflection across Schemas [message #415810 is a reply to message #415794] Wed, 29 July 2009 06:50 Go to previous messageGo to next message
Frank
Messages: 7901
Registered: March 2000
Senior Member
Not sure about these specific classes, but I remember that Oracle used to put a lot of propriety stuff in classes12.zip
Re: Java Stored Procedure, Reflection across Schemas [message #415816 is a reply to message #415810] Wed, 29 July 2009 07:09 Go to previous message
mike__porter@hotmail.com
Messages: 3
Registered: July 2009
Junior Member
yeah, searched through a lot of them, can't find it yet. I think those are in some jars on the database side, not on the client...and then resolved during loadjava on the server?
Previous Topic: Create new folder under web content
Next Topic: how do i filter out the node which has attribute value equal empty
Goto Forum:
  


Current Time: Mon Dec 09 20:11:51 CST 2024