Hi Rajesh,
A little curious about what you are trying to do.
In the code:
1. Class cls = Class.forName(strClassType);
2. Object o1 = cls.newInstance();
3. o1 = cspSltTest.getValue(iRowIndex,
COLUMN_NAME);
I see that the assignment to o1 in line2 is being overridden in
line3. Did you miss some line of code?
Anyway, out of curiosity I tried this code without line 3. I put it into a
Hashtable and pulled it out later as an empty CSpString without any probelm
(and also confirmed that I got a CSpString using instanceof.)
I think the problem lies elsewhere.
Regards,
Aby
> -----Original Message-----
> From: Lakshmanamurthy, Rajesh [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, May 18, 1999 6:31 PM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: [ND] Problem with reflection & dynamic object creation
>
> Hello NetDyners,
>
> I am trying to use the java.lang.reflection to dynamically instance
> a class object based on a variable, contains the name of the class.
> as shown. The strClassName can be anything, spider.session.CSpString,
> spider.session.CSpInteger, etc.
>
>
> cspSltTest -is a dataObject.
> strClassName - "spider.session.CSpString"
>
>
> Class cls = Class.forName(strClassType);
> Object o1 = cls.newInstance();
> o1 = cspSltTest.getValue(iRowIndex, COLUMN_NAME);
>
> & try using it like say,
>
> cspH1.put(strKey, (CSpValue) o1)
>
> where cspH1 is a CSpHashTable.
>
> This throws the following error.( shown at the end)
>
> The error message says: Local class not compatible
>
> Any help or suggestions will be greatly appreciated.
>
> Thanks,
> Raj
>
>
> CSpFileBased.deserializeObject: Unexpected Exception
> (java.io.InvalidClassException: DIAMONDWEB.NDDiamondPage; Local class not
> compatible: stream classdesc serialVersionUID=-8717881427890931675 local
> class serialVersionUID=-2504985847882855499) caught. Top of
> stack: |java.io.InvalidClassException: DIAMONDWEB.NDDiamondPage;
> Local class not compatible: stream classdesc
> serialVersionUID=-8717881427890931675 local class
> serialVersionUID=-2504985847882855499 at
> java.lang.Throwable.<init>(Compiled
> Code) at
> java.lang.Exception.<init>(Compiled Code) at
> java.io.IOException.<init>(IOException.java:45) at
> java.io.ObjectStreamException.<init>(ObjectStreamException.java:30) at
> java.io.InvalidClassException.<init>(InvalidClassException.java:49) at
> java.io.ObjectStreamClass.setClass(Compiled Code) at
> java.io.ObjectInputStream.inputClassDescriptor(Compiled Code) at
> java.io.ObjectInputStream.readObject(Compiled Code) at
> java.io.ObjectInputStream.readObject(Compiled Code) at
> java.io.ObjectInputStream.inputClassDescriptor(Compiled Code) at
> java.io.ObjectInputStream.readObject(Compiled Code) at
> java.io.ObjectInputStream.readObject(Compiled Code) at
> java.io.ObjectInputStream.inputObject(Compiled Code) at
> java.io.ObjectInputStream.readObject(Compiled Code) at
> java.io.ObjectInputStream.readObject(Compiled Code) at
> spider.CSpFileBased.deserializeObject(Compiled Code) at
> spider.CSpProject.deserializeAndInitAnObject(Compiled Code) at
> spider.CSpProject.getCommonPage(Compiled Code) at
> spider.CSpider.getCommonPage(Compiled Code) at
> spider.CSpider.getCommonPage(Compiled Code) at
> spider.util.CSpCommonPageRef.resolveObjectReference(Compiled Code) at
> spider.CSpFileBased.resolveObjectRef(Compiled Code) at
> spider.visual.CSpHtmlFrame.afterInit(Compiled Code) at
> spider.CSpFileBased.afterInitList(Compiled Code) at
> spider.visual.CSpVisual.afterInit(Compiled Code) at
> spider.visual.CSpCommonPage.afterInit(Compiled Code) at
> spider.visual.CSpCommonHtmlPage.afterInit(Compiled Code) at
> s
> _________________________________________________________________________
>
> For help in using, subscribing, and unsubscribing to the discussion
> forums, please go to: http://www.netdynamics.com/support/visitdevfor.html
>
> For dire need help, email: [EMAIL PROTECTED]
_________________________________________________________________________
For help in using, subscribing, and unsubscribing to the discussion
forums, please go to: http://www.netdynamics.com/support/visitdevfor.html
For dire need help, email: [EMAIL PROTECTED]