Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

StackOverflowError

Posted on 2011-09-22
5
Medium Priority
?
213 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
[X]
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
  • 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 2000 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
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.
Suggested Courses

618 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