Applet Crashes on Firefox.


S

Sanny

I have an Applet which works fine on my system and many other systems.

But a Web Visitor using my applet on Firefox. His Applet Crashes
giving below error. He has latest Java Plugins Installed.

Exception in thread "AWT-EventQueue-3"
java.lang.StringIndexOutOfBoundsException: String index out of range:
73
at java.lang.String.charAt(Unknown Source)
at aaa.myapplet.paint(myapplet.java:4271)
at aaa.myapplet.update(myapplet.java:3641)
at sun.awt.RepaintArea.updateComponent(Unknown Source)
at sun.awt.RepaintArea.paint(Unknown Source)
at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


Looks like The StringIndexOutOfBoundsException is the reasion.

But when I try that applet on my computer It do not give any error?

What may be the possible reasion for this error?

Bye
Sanny
 
Ad

Advertisements

K

Knute Johnson

Sanny said:
I have an Applet which works fine on my system and many other systems.

But a Web Visitor using my applet on Firefox. His Applet Crashes
giving below error. He has latest Java Plugins Installed.

Exception in thread "AWT-EventQueue-3"
java.lang.StringIndexOutOfBoundsException: String index out of range:
73
at java.lang.String.charAt(Unknown Source)
at aaa.myapplet.paint(myapplet.java:4271)
at aaa.myapplet.update(myapplet.java:3641)
at sun.awt.RepaintArea.updateComponent(Unknown Source)
at sun.awt.RepaintArea.paint(Unknown Source)
at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


Looks like The StringIndexOutOfBoundsException is the reasion.

But when I try that applet on my computer It do not give any error?

What may be the possible reasion for this error?

Bye
Sanny

The index of 73 is not in the available range. You want a better answer
than that you need to provide some source code.
 
S

Sanny

The index of 73 is not in the available range.  You want a better answer
than that you need to provide some source code.

Is this error comming in PAINT() function of applet?

Then I can search the paint() code and find which String is searched
at 73 index.

Thanks
Sanny
 
K

Knute Johnson

Sanny said:
Is this error comming in PAINT() function of applet?

Then I can search the paint() code and find which String is searched
at 73 index.

Thanks
Sanny

at aaa.myapplet.paint(myapplet.java:4271)
 
M

Mike Amling

Sanny said:
I have an Applet which works fine on my system and many other systems.

But a Web Visitor using my applet on Firefox. His Applet Crashes
giving below error. He has latest Java Plugins Installed.

Exception in thread "AWT-EventQueue-3"
java.lang.StringIndexOutOfBoundsException: String index out of range:
73
at java.lang.String.charAt(Unknown Source)
at aaa.myapplet.paint(myapplet.java:4271)
at aaa.myapplet.update(myapplet.java:3641)

What's on line 4271 of myapplet.java?

--Mike Amling
 
L

Lew

There is no 'PAINT' method in applets, unless you extended the applet type and
added your own.

Unlikely - it'll have been a String in your code, not the API's.

You'll have better luck looking where
Knute said:
at aaa.myapplet.paint(myapplet.java:4271)

The trick is to scan down the stack trace until you get to the deepest
call-stack level in your own code. Your code is almost always more likely to
be the culprit than 3rd-party code.
 
Ad

Advertisements

N

Nigel Wade

Is this error comming in PAINT() function of applet?

Then I can search the paint() code and find which String is searched at
73 index.


You should look at the GUI initialization and manipulation with respect
to threads. Problems within the event dispatch thread (especially ones
which are intermittent or only occur on one platform whilst running on
others) are commonly due to attempting to initialize or modify the GUI on
the main thread rather than the EDT. This creates potential race
conditions where events triggered on the EDT attempt to render components
which are in the process of being modified on another thread.

Given that the error is a StringIndexOutOfBoundsException it looks like
at some point the String was longer than 73, but by the time the EDT gets
to rendering it it has changed length. This smacks of unsynchronized
access to some Component by two threads.

You've just been lucky up to now on your computer.
 
S

Sanny

Is this error comming in PAINT() function of applet?
PROBLEM SOLVED: Using a Global Variable in 2 threads. Both were
changing the value creating confusion. Now I use local variables in
both threads.
You should look at the GUI initialization and manipulation with respect
to threads. Problems within the event dispatch thread (especially ones
which are intermittent or only occur on one platform whilst running on
others) are commonly due to attempting to initialize or modify the GUI on
the main thread rather than the EDT. This creates potential race
conditions where events triggered on the EDT attempt to render components
which are in the process of being modified on another thread.

The bug was found.

It happened there were 2 threads and they were using a temporary
Global Variable.

So when both threads stored some value in that temporary Global
variable. The values were changed by other thread.

So The .charAt(ggg) The value of ggg was changed by other thread and
it got StringIndexOutOfBoundsException

I have corrrected the problem by using local variables in both
threads.

I hope now the problem will be solved. I have yet to communicate with
the Web Visitors to know the modifications have corrected the problem
or not.

Thankyou a lot foe your good suggestions.

Bye
Sanny
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top