Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

StackOverflowError

Posted on 2011-09-22
5
207 Views
Last Modified: 2012-05-12
A customer is receiving a StackOverflowError with a 1024 lines of the following:
at java.awt.AWTEventMulticaster.mouseMoved(AWTEventMulticaster.java:312)

This happens over and over.

This is being reported by a customer and I am at a loss as to which component is causing it and I can't seem to duplicate it myself.  What might be causing this or what should I be looking for?

Thanks.
0
Comment
Question by:gpman65
  • 3
5 Comments
 
LVL 4

Expert Comment

by:stachenov
ID: 36581722
Usually this happens because of infinite recursion, but I can't think of any possible way to cause infinite recursion with this class. Well, except for subclassing it and passing "this" to the superclass constructor, but that's not something easily done by mistake. When used in normal way, add() functions create nodes at the root of the listener tree, and there is no way to change deeper nodes to point above themselves, thus creating an event loop.

Perhaps it is not an infinite recursion, but just too much listeners in the tree? Although it is quite hard to imagine having that many listeners.

Or it could be that one of the listeners calls the root listener recursively. But then that particular listener would turn up in the stack trace as well, which apparently isn't happening. Of course it is possible that it also adds another listener at the top of the tree and only then calls the (new) top listener. This sounds too crazy to be true, but it would lead to the tree constantly growing until it gets too large.

Sorry for being so vague, but it is hard to say more without more details about how multicasters are used.
0
 
LVL 4

Accepted Solution

by:
stachenov earned 500 total points
ID: 36581802
Come to think of it, it is not necessary that listeners are added inside other listeners. The "too many listeners" case could be caused by something (anywhere in the program) periodically adding those listeners until the tree grows too large. So the first thing to check is all add() calls. How often are they called? Don't they add the same listeners again and again?

Another thing to do is to change the order of the arguments for add(). The thing is that the listeners are called in the order they are passed to add(). If the listener returned by the previous invocation of add() is passed first, then the event is first propagated down to the deepest node and then listeners are called while the stack "unwinds". The bad thing is that in this case all you get is those "AWTEventMulticaster.java:312" lines. On the other hand, if the root listener returned by add() is passed as the second argument, then it would call the latest listener first, then go down by one level, call the previous listener, and so on. The order would be reversed, but you'll see in the stack trace which listeners are being called, and that could mean easier debugging.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36581813
Are you running it in the same version of Java as your customer?
0
 
LVL 4

Expert Comment

by:stachenov
ID: 36581849
Regarding my last comment: even if the order of the listeners is reversed, you'll only see the listener that was called last, and only if you're lucky enough. Still, it is better than nothing I guess.
0
 

Author Closing Comment

by:gpman65
ID: 36581926
I found where I was adding the same listener over and over again.  I would not have expected a stackoverflow from this, but that does seem to be the cause.  Thanks.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Oracle SQL syntax check  without executing 6 74
javap not working 8 58
Facing this issue for maven proxy setting 2 20
JAVA API design with micro service cloud in mind 1 44
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question