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

  • Home
  • SEARCH
  • 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 8149209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:48:14+00:00 2026-06-06T14:48:14+00:00

I have this piece of code List<Class<? extends SubApplication>> appClasses = new ArrayList<Class<? extends

  • 0

I have this piece of code

List<Class<? extends SubApplication>> appClasses = new ArrayList<Class<? extends SubApplication>>();
List<SubApplication> subApps = new ArrayList<SubApplication>();

// instructions filling "appClasses"
// ... other instructions

for (Class<? extends SubApplication> crtClass : appClasses) {
    try {
        Constructor<? extends SubApplication> constructor = crtClass.getConstructor(new Class<?>[] { Application.class });
        SubApplication subApp = constructor.newInstance(this);
        if (!subApps.contains(subApp)) {
            subApps.add(subApp);
        }
    } catch (SecurityException e) {
    } catch (NoSuchMethodException e) {
    } catch (IllegalArgumentException e) {
    } catch (InstantiationException e) {
        System.out.println(e.getMessage());
    } catch (IllegalAccessException e) {
    } catch (InvocationTargetException e) {
    }
}

whereas this is an instance of Application.

I have several implementations of SubApplication. It’s part of the contract that all subclasses of this class need to implement a constructor taking a Application as parameter.

Now I always receive an InstanciationException even though I exactly known that the subclass contains such a constructor. Further details on the exception aren’t available: getMessage() returns null


Edit: SubApplication is abstract. But appClasses only contains sub-classes of SubApplication


Edit2: I had to “construct” the stacktrace, because by contract, I have to catch the exception.

sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:30)
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
ch.migros.gmaare.tk.auth.gui.AuthenticableApp.instanciateSubApps(AuthenticableApp.java:64)
ch.migros.gmaare.tk.auth.gui.AuthenticableApp.<init>(AuthenticableApp.java:42)
ch.migros.gmaare.tk.voicesuite.VoicesuiteApplication.<init>(VoicesuiteApplication.java:34)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
java.lang.Class.newInstance0(Class.java:355)
java.lang.Class.newInstance(Class.java:308)
com.vaadin.terminal.gwt.server.ApplicationServlet.getNewApplication(ApplicationServlet.java:82)
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.createApplication(AbstractApplicationServlet.java:978)
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.findApplicationInstance(AbstractApplicationServlet.java:801)
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:456)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Thread.java:662)

Any idea is appreciated.

  • 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-06-06T14:48:16+00:00Added an answer on June 6, 2026 at 2:48 pm

    As described in the comments. I was dumb enough from not to verify the classes names in my array. Actually, I’ve really added SubApplication to the list. Thanks for your inputs anyway!

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

Sidebar

Related Questions

I have this small piece of code that basically takes a list and runs
I have this piece of code: @Entity @Table(name = MOVERS) public class MOVers implements
I have written this piece of code public class Test{ public static void main(String[]
I have this piece of code <?php for ($i=0;$i<sizeof($list[tags]); $i++) { if ($list[tags][$i][title]=='list') {
I have a piece of code public class Radio_groupActivity extends ListActivity { TextView selection;
I have this piece of code in a function. I want to print the
I have this piece of code: public static DateDialogFragment newInstance(Context context, DateDialogFragmentListener listener) {
I have this piece of code for my images, so the opacity can lower
I have this piece of code, <div id=event style=display:none;> <!-- initially hidden --> <div
I have this piece of code which check the last customer_id from the db.

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.