This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Java in General and the fly likes InvocationTargetException thrown when try to save in Vector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "InvocationTargetException thrown when try to save in Vector" Watch "InvocationTargetException thrown when try to save in Vector" New topic
Author

InvocationTargetException thrown when try to save in Vector

tanu dua
Ranch Hand

Joined: Apr 05, 2004
Posts: 145
Hi,

I created one object using reflection and then try to save that object in the Vector , I have got InvocationTargetException , however while storing it into the reference type of that object , it works fine.

Before storing it into the vector , I printed out the object created , and it shows the classname@hashcode means that object is created successfully.

I tried storing it in Vector,ArrayList and static arry of that objects but no luck.

Can someone help me in debugging this issue . I understand the information provide by me may be vague but still if someone has any idea or encountered the same issue , please help me out.

Thanks
Tanu
Scott Escue
Ranch Hand

Joined: Jan 20, 2005
Posts: 34
Tanu,

Could you post a code snippet showing how you're creating the object and adding it to the Vector? Also, what is the cause of your InvocationTargetException? You can call the <exception>.getCause() method to find out for certain.
tanu dua
Ranch Hand

Joined: Apr 05, 2004
Posts: 145
Thanks Scott.

I could able to solve the problem . I was using the instance variable of Vector in my class , I tried using the method variable of vector and tried to save the object , it worked.

I am not sure why is that but luckily it worked for me .

Sorry I cant post you code as you will not be able to understand the code as its very tightly coupled with our custom infrastructure.

Anyway Thanks and if you have any idea how it worked , please share
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


Sorry I cant post you code as you will not be able to understand the code as its very tightly coupled with our custom infrastructure.

Tightly coupled and using reflection? You may be right, but you could try us any way. Otherwise we can only guess.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Hi Tanu,

Try this:
InvocationTargetException is a checked exception that wraps an exception thrown by an invoked method or constructor.

As of release 1.4, this exception has been retrofitted to conform to the general purpose exception-chaining mechanism. The "target exception" that is provided at construction time and accessed via the getTargetException() method is now known as the cause, and may be accessed via the Throwable.getCause() method, as well as the aforementioned "legacy method."


Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
Scott Escue
Ranch Hand

Joined: Jan 20, 2005
Posts: 34
Anyway Thanks and if you have any idea how it worked , please share


Paul is right, without more information we have no idea. If using the method local variable solves your problem, that's cool. But if you still need to get it to work with your instance variable, you'll need to post some code and/or more details on the exception your getting.
[ April 18, 2007: Message edited by: Scott Escue ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: InvocationTargetException thrown when try to save in Vector
 
Similar Threads
jsp error
Copy Data From One Database to other using hibernate ?
Enable Mailing services
File upload in Struts
how to store a file in the local hard disk