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 8321837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:09:46+00:00 2026-06-08T23:09:46+00:00

UPDATE NOTE: After Debugging, I asked another question with the results: Class Constructor fails

  • 0

UPDATE NOTE: After Debugging, I asked another question with the results: Class Constructor fails throwing Exception on Class Loading

First, I could not think of a better name for my question, what I’m about to ask is just that: WEIRD BEHAVIOR. If you think of something more appropriate please edit.

Now, I’m going to try to simplify this as much as I can, sadly I can’t give away the code which is giving me the problems.

I have a Class A, a Class B and a Class Z.

Class A and B are very very similar, both have a constructor with the same params, and each have a method which invokes a SOAP web service, one to do Operation A, and the other to do Operation B.

Now,what’s the problem? Class Z instantiates both Class A and Class B and then on someMethod() calls the object’s method to do Operation A and B respectively.

For some reason the constructor of ClassB doesn’t seem to be called, and no System.out.println() prints anything from the moment the Constructor is called, the program hangs forever, i mean it, it never throws and exception or continues to do anything. Look how on the first line of Class A and Class B I print a flag, it does not print for ClassB.

WHAT I’VE TRIED

  1. On ClassZ I changed the order for Class A and B -> RESULTS: It hangs on the same place and now not even Class A constructor and method gets called
  2. On ClassB I commented everything, and started de-commenting each instruction one by one, starting with the Constructor and then with MethodB, here’s where I got stuck and came here, because what I found makes no sense for me nor anybody at my workplace. RESULTS ->

    2.1 If I comment everything on methodB but the return false in the end and leave the Constructor as is, it continues execution normally

    2.2 If I de-comment everything on 2.1 plus just the part from methodB where it invokes the operationB from the WebService and checks it’s result, it continues execution normally

    2.3 If I de-comment a little bit more, when I start playing around with the database, it hangs.

  3. I checked the number of Connections to the Database, it still has many available

What has me confused is, if it’s something Database related, why does it hangs like that at the constructor?

GENERAL FACTS

  1. I’m using JDBC to connect to a MySQL Database
  2. I have everything around try{}catch(Exception e){} and I’m printing everything on e, but it just doesn’t print anything, no exception is thrown.

Here’s what they look like:

CLASS A:

// ClassA.java

public ClassA{
    private UserInfo user;
    private WebServiceADelegate port;
    private Connection conn;

    public ClassA (UserInfo user, Connection conn) throws Exception {
        System.out.println("CLASS A CONSTRUCTOR");
        this.user = user;
        this.conn = conn;
        this.port = new WebServiceAService().getForwardingPort();
    }

    public boolean methodA(List<String> list){
        // Check some stuff on database using this.conn
        // Get the values to invoke SOAP service using this.conn
        status = port.operationA(values);
        if(status > 0)
            return true;
        return false;
    }

}

CLASS B:

// ClassB.java

public ClassB{
    private UserInfo user;
    private WebServiceBDelegate port;
    private Connection conn;

    public ClassB (UserInfo user, Connection conn) throws Exception {
        System.out.println("CLASS B CONSTRUCTOR");
        this.user = user;
        this.conn = conn;
        this.port = new WebServiceBService().getForwardingPort();
    }

    public boolean methodB(List<String> list){
        // Check some stuff on database using this.conn
        // Get the values to invoke SOAP service using this.conn
        status = port.operationB(values);
        if(status > 0)
            return true;
        return false;
    }

}

CLASS Z:

// ClassZ.java

public ClassZ{
    private Connection conn;
    // ...        
    // ...
    public boolean someMethod (){
        System.out.println("GONNA CALL CONSTRUCTOR ClassA");
        ClassA webservice = new ClassA(user, conn);
        System.out.println("GONNA CALL METHOD FROM ClassA");
        if (!webservice.methodA(list) ){
            return false;
        }

        System.out.println("GONNA CALL CONSTRUCTOR ClassB");
        ClassB webservice2 = new ClassB(user, conn);
        System.out.println("GONNA CALL METHOD FROM ClassB");
        if (!webservice2.methodB(list) ){
            return false;
        }
        return true;
    }
}

The last output when it hangs it’s always: "GONNA CALL CONSTRUCTOR ClassB"

Thanks!

UPDATE:

I debugged my app and got to fix it, however it’s still really strange. Tomorrow I’ll elaborate more to see if somebody can tell me what was going on.

Long story short: I was importing javax.persistence.NoResultException on ClassB, and on some point inside methodB i was doing try{}catch(NoResultException nre){ //...}… For some reason when the JVM was calling the ClassLoader before calling the Constructor it was throwing the aforementioned Exception and the behavior from that point was just weird and the execution ended.

There are threads involved, that’s why I though it hang, it didn’t hang, the Thread ended and I didn’t notice.

An additional note: ClassB IS NOT using JPA, and the import as well as the catch for it were incorrectly there, some really old code that managed to survive. However I think it doesn’t justify the error.

I asked another question, one with the findings of the Debugging. You might check it in Class Constructor fails throwing Exception on Class Loading

  • 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-08T23:09:48+00:00Added an answer on June 8, 2026 at 11:09 pm
    1. The application didn’t hang forever. This piece of code was running in another thread so when its execution failed it finished without me noticing.
    2. The problem was in fact when calling the constructor. I didn’t have the class javax.persistence.NoResultException on my classpath so the JVM ClassLoader couldn’t find it when creating the instance and when checking for dependencies it crashed.
    3. Finding out what was the problem was difficult even debugging because I had a lot of
      try{}catch(Exception e){} but even though the ClassLoader.loadClass() of the JVM ClassLoader says it throws an Exception (ClassLoader.loadClass() signature is: public Class<?> loadClass(String name) throws ClassNotFoundException) it was actually throwing a NoClassDefFoundError, which DOES NOT EXTEND EXCEPTION, it extends Throwable, and therefore was not being catch by my catch(Exception e){}, I had to do catch(Throwable t){}.
    4. As of why was it throwing something different, it’s because how Java’s internals class loading works. It’s a bit more complicated than just calling loadClass. It has to load, link, verify and initialize it. At some point it is supposed to throw a NoClassDefFoundError when calling defineClass(). More on this can be found on the Execution part of the JLS

    For a more detailed answer on what was heppening, check my other question regarding this issue after debugging and the accepted answer Class Constructor fails throwing Exception on Class Loading

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

Sidebar

Related Questions

Note : This question has been re-asked with a summary of all debugging attempts
Got this message today after running bundle update : $ bundle update NOTE: Gem::SourceIndex#all_gems
On the IOC Castle Windsor wiki [Editor's Note: After this question was written, the
Note: I ended up answering my own question shortly after posting this. Thanks and
NOTE: I added my new solution at the UPDATE answer below. I try to
Note(update): No need to read this entire wall of text.. problem + solution further
I have a Form with a listview. After calling Form.Show I need to update
Update: Note that this thread does not applyt o recent versions of Emacs (24+).
Note: This is not a question whether I should use list or deque. It's
After gem update --system , when I do something related to rubygems, I receive

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.