?
Solved

StackOverflowError

Posted on 2011-09-22
5
Medium Priority
?
210 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses
Course of the Month9 days, 1 hour left to enroll

764 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