Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4036492
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:13:47+00:00 2026-05-20T12:13:47+00:00

I am using class.forname to create a new instance of class.The classname comes from

  • 0

I am using class.forname to create a new instance of class.The classname comes from a properties.

Lets say i have several classes in two packages.

com.package.Parser1
com.package.Parser2
com.package.Parser3

net.package.parser4
net.package.parser5
net.package.parser6

The following classes also exist in the above packages (This are not instantiated)

com.package.ParserLoader
com.package.ParserInterface
net.package.GenericParser

On initialisation, the above parser are put in a vector. The vector is then accessed and each class is initialised using its class name as shown below

while (tokens.hasMoreTokens())

        parsers.addElement(

            Class.forName((String) tokens.nextToken()).newInstance());
    }catch(Exception e){
        e.printStackTrace();
    }

The code above is in the class ParserLoader which is in the same package as parsers 1,2,3.

Parsers 1, 2 and 3 all implement the ParserInterface.
Parsers 4,5 and 6 all extends the abtract GenericParser.
The GenericParser implements the ParserInterface.

When i run the above it generates an exception shown below

com.sun.jdi.InvocationException occurred invoking method

Any ideas why this is happening?

Edit

Another problem i am having is i cant see any stack trace. There is no stacktrace! I only see that error in eclipse when i debug the application and look at the content of the parsers vector. The vector should contain references to the parser objects. The parsers in com.package.* package are fine but it is not creating instances of any parser in the net.package.* package.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:13:47+00:00Added an answer on May 20, 2026 at 12:13 pm

    I think you’ll get this exception if your constructors are messed up or something else is broken while creating the parsers. Check this out: http://download.oracle.com/javase/6/docs/jdk/api/jpda/jdi/com/sun/jdi/InvocationException.html, and try to get more info out of your exception.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i load a class using Class.forName(klassname,false,loader) After this i create an instance using klass.newInstance();
Let's say we have 2 classes A and B public class A{ private int
I would like to create an instance of a specified class using its name.
We can use reflection to create the objects. Let's say I have a class
Lets say I have a class named Dog which is a subclass of Animal
I am using following prepared statement : Class.forName(com.mysql.jdbc.Driver); con=DriverManager.getConnection(jdbc:mysql://localhost:3306/mysql,root,root); String query=select ename from ?
When loading the class, using method forName() , any static initializers in the class
I am trying to create a new instance of Couple with the given name
I'm trying to create an object of a class, using just a name of
I am trying to create new instances of a class (specifically a subclass of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.