Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

InvocationTargetException thrown when try to save in Vector

 
tanu dua
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Srinivasan thoyyeti
Ranch Hand
Posts: 557
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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."
 
Scott Escue
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic