I have a class object and there are 2 getters in that with values. For some reason am getting classcastexception(weblogic class loader issue(not able to cast)). Is there any way I can get the values using reflection API or some other API. Please check.
I tried all the possibilities. Now only way is I have to get the values without type casting the class object.
But I think there might be more to your question: When do you get a ClassCastException? Can you show us some code that causes the ClassCastException and be more specific about precisely what you want to do?
Post by:Meet Gaurav
, Ranch Hand
return type of the method which am calling is String. field.get(obj) is giving illegalAccess Exception. Is there any limitation ? Please help.
Post by:Jesper de Jong
This sounds like an example of the XY problem: you have some problem X (you're getting a ClassCastException), and you think that solution Y (reflection) will solve it. So you ask how to apply solution Y, without explaining what your problem X really is.
So, can you show us your code and explain exactly where you're getting a ClassCastException and what exactly the exception message is? Maybe we can then help you solve problem X, instead of giving you some tips for the wrong solution Y. Reflection is not magically going to help you bypass a ClassCastException.
In your last post you're mentioning IllegalAccessException. So is it ClassCastException or IllegalAccessException? Or are you having two problems at the same time?