• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

InvocationTargetException thrown when try to save in Vector

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
That is a really big piece of pie for such a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic