- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
actors in applets: problem if return to the page
Thu, 2009-04-02, 15:10
Dear all,
I'm encountering a problem if I return to a web page containing an applet that's using actors.
For a demonstration, the following page has the applet links:
http://lafros.com/Misc/actors-applet
There is also a problem if I reload the page, although this appears to be confined to the JDK 1.5 browser plug-in.
If anyone has any ideas about how to fix this, please could they respond.
The following tickets have been created:
actors cannot tolerate page reloads in JDK 1.5 plug-in applets
https://lampsvn.epfl.ch/trac/scala/ticket/1688
actors cannot tolerate returning to JDK 1.5 or 1.6 plug-in applet pages
https://lampsvn.epfl.ch/trac/scala/ticket/1848
Thanks,
--
Rob, Lafros.com
I'm encountering a problem if I return to a web page containing an applet that's using actors.
For a demonstration, the following page has the applet links:
http://lafros.com/Misc/actors-applet
There is also a problem if I reload the page, although this appears to be confined to the JDK 1.5 browser plug-in.
If anyone has any ideas about how to fix this, please could they respond.
The following tickets have been created:
actors cannot tolerate page reloads in JDK 1.5 plug-in applets
https://lampsvn.epfl.ch/trac/scala/ticket/1688
actors cannot tolerate returning to JDK 1.5 or 1.6 plug-in applet pages
https://lampsvn.epfl.ch/trac/scala/ticket/1848
Thanks,
--
Rob, Lafros.com
Thu, 2009-04-02, 17:07
#2
Re: actors in applets: problem if return to the page
Trond,
Okay will try maintaining a reference, and have the destroy() use it to tell the actor to exit().
Thanks,
Rob
2009/4/2 Trond Olsen <tolsen77@gmail.com>
Okay will try maintaining a reference, and have the destroy() use it to tell the actor to exit().
Thanks,
Rob
2009/4/2 Trond Olsen <tolsen77@gmail.com>
I guess you'll have to manually reference all actors and do a cleanup when your applet exit or is there a simple "kill-switch" for them? I retried my applet with browsing back and forth and the old actors also responds when I communicate from Javascript.
On Thu, Apr 2, 2009 at 4:08 PM, Rob Dickens <arctic.bob@googlemail.com> wrote:Dear all,
I'm encountering a problem if I return to a web page containing an applet that's using actors.
For a demonstration, the following page has the applet links:
http://lafros.com/Misc/actors-applet
There is also a problem if I reload the page, although this appears to be confined to the JDK 1.5 browser plug-in.
If anyone has any ideas about how to fix this, please could they respond.
The following tickets have been created:
actors cannot tolerate page reloads in JDK 1.5 plug-in applets
https://lampsvn.epfl.ch/trac/scala/ticket/1688
actors cannot tolerate returning to JDK 1.5 or 1.6 plug-in applet pages
https://lampsvn.epfl.ch/trac/scala/ticket/1848
Thanks,
--
Rob, Lafros.com
Fri, 2009-04-03, 04:48
#3
Re: actors in applets: problem if return to the page
Updated my own code with a Exit() message for manual release of all the actors and the applet now exits properly with back-forward on history.
On Thu, Apr 2, 2009 at 5:58 PM, Rob Dickens <arctic.bob@googlemail.com> wrote:
On Thu, Apr 2, 2009 at 5:58 PM, Rob Dickens <arctic.bob@googlemail.com> wrote:
Trond,
Okay will try maintaining a reference, and have the destroy() use it to tell the actor to exit().
Thanks,
Rob
2009/4/2 Trond Olsen <tolsen77@gmail.com>
I guess you'll have to manually reference all actors and do a cleanup when your applet exit or is there a simple "kill-switch" for them? I retried my applet with browsing back and forth and the old actors also responds when I communicate from Javascript.
On Thu, Apr 2, 2009 at 4:08 PM, Rob Dickens <arctic.bob@googlemail.com> wrote:Dear all,
I'm encountering a problem if I return to a web page containing an applet that's using actors.
For a demonstration, the following page has the applet links:
http://lafros.com/Misc/actors-applet
There is also a problem if I reload the page, although this appears to be confined to the JDK 1.5 browser plug-in.
If anyone has any ideas about how to fix this, please could they respond.
The following tickets have been created:
actors cannot tolerate page reloads in JDK 1.5 plug-in applets
https://lampsvn.epfl.ch/trac/scala/ticket/1688
actors cannot tolerate returning to JDK 1.5 or 1.6 plug-in applet pages
https://lampsvn.epfl.ch/trac/scala/ticket/1848
Thanks,
--
Rob, Lafros.com
Fri, 2009-04-03, 10:57
#4
Re: actors in applets: problem if return to the page
Still can't get it to work, even doing the following:
* applet init: actor = new MyActor; actor.start()
* applet destroy: actor ! cmds.exit; actor = null
* class MyActor: breaks out of receive loop on receipt of cmds.exit, and calls exit
When I return to the page, and actor.start() is called, I get the following:
new instance created
init()
java.lang.IllegalThreadStateException
at java.lang.ThreadGroup.add(ThreadGroup.java:846)
at java.lang.Thread.start(Thread.java:596)
at scala.actors.FJTaskRunnerGroup.signalNewTask(Unknown Source)
at scala.actors.FJTaskRunnerGroup.execute(Unknown Source)
at scala.actors.FJTaskScheduler2.execute(FJTaskScheduler2.scala:164)
at scala.actors.Scheduler$.execute(Scheduler.scala:91)
at scala.actors.Actor$class.start(Actor.scala:782)
at com.lafros.MyActor.start(ActorsApplet.scala:30)
at com.lafros.ActorsApplet.init(ActorsApplet.scala:13)
at sun.applet.AppletPanel.run(AppletPanel.java:424)
at java.lang.Thread.run(Thread.java:619)
2009/4/3 Trond Olsen <tolsen77@gmail.com>
* applet init: actor = new MyActor; actor.start()
* applet destroy: actor ! cmds.exit; actor = null
* class MyActor: breaks out of receive loop on receipt of cmds.exit, and calls exit
When I return to the page, and actor.start() is called, I get the following:
new instance created
init()
java.lang.IllegalThreadStateException
at java.lang.ThreadGroup.add(ThreadGroup.java:846)
at java.lang.Thread.start(Thread.java:596)
at scala.actors.FJTaskRunnerGroup.signalNewTask(Unknown Source)
at scala.actors.FJTaskRunnerGroup.execute(Unknown Source)
at scala.actors.FJTaskScheduler2.execute(FJTaskScheduler2.scala:164)
at scala.actors.Scheduler$.execute(Scheduler.scala:91)
at scala.actors.Actor$class.start(Actor.scala:782)
at com.lafros.MyActor.start(ActorsApplet.scala:30)
at com.lafros.ActorsApplet.init(ActorsApplet.scala:13)
at sun.applet.AppletPanel.run(AppletPanel.java:424)
at java.lang.Thread.run(Thread.java:619)
2009/4/3 Trond Olsen <tolsen77@gmail.com>
Updated my own code with a Exit() message for manual release of all the actors and the applet now exits properly with back-forward on history.
On Thu, Apr 2, 2009 at 5:58 PM, Rob Dickens <arctic.bob@googlemail.com> wrote:
Trond,
Okay will try maintaining a reference, and have the destroy() use it to tell the actor to exit().
Thanks,
Rob
2009/4/2 Trond Olsen <tolsen77@gmail.com>
I guess you'll have to manually reference all actors and do a cleanup when your applet exit or is there a simple "kill-switch" for them? I retried my applet with browsing back and forth and the old actors also responds when I communicate from Javascript.
On Thu, Apr 2, 2009 at 4:08 PM, Rob Dickens <arctic.bob@googlemail.com> wrote:Dear all,
I'm encountering a problem if I return to a web page containing an applet that's using actors.
For a demonstration, the following page has the applet links:
http://lafros.com/Misc/actors-applet
There is also a problem if I reload the page, although this appears to be confined to the JDK 1.5 browser plug-in.
If anyone has any ideas about how to fix this, please could they respond.
The following tickets have been created:
actors cannot tolerate page reloads in JDK 1.5 plug-in applets
https://lampsvn.epfl.ch/trac/scala/ticket/1688
actors cannot tolerate returning to JDK 1.5 or 1.6 plug-in applet pages
https://lampsvn.epfl.ch/trac/scala/ticket/1848
Thanks,
--
Rob, Lafros.com
Fri, 2009-04-03, 18:37
#5
Re: actors in applets: problem if return to the page
Not sure what that error is, but I did notice that the tray icon for Java goes away when I now go back-forward. I'm only using the latest 1.6 release though.
Here's the code that I used
// my exit case class
object Application {
case class Exit()
}
// on applet.destroy
myActor ! Application.Exit()
// message handling loop in the actors
loop {
try {
react {
case Application.Exit() => exit
case msg @ _ => error("Unhandled actor message " + msg + " found")
}
}
catch {
case exp: Exception => // error handling
case exp: java.lang.NullPointerException => // error handling
}
}
On Fri, Apr 3, 2009 at 11:54 AM, Rob Dickens <arctic.bob@googlemail.com> wrote:
Here's the code that I used
// my exit case class
object Application {
case class Exit()
}
// on applet.destroy
myActor ! Application.Exit()
// message handling loop in the actors
loop {
try {
react {
case Application.Exit() => exit
case msg @ _ => error("Unhandled actor message " + msg + " found")
}
}
catch {
case exp: Exception => // error handling
case exp: java.lang.NullPointerException => // error handling
}
}
On Fri, Apr 3, 2009 at 11:54 AM, Rob Dickens <arctic.bob@googlemail.com> wrote:
Still can't get it to work, even doing the following:
* applet init: actor = new MyActor; actor.start()
* applet destroy: actor ! cmds.exit; actor = null
* class MyActor: breaks out of receive loop on receipt of cmds.exit, and calls exit
When I return to the page, and actor.start() is called, I get the following:
new instance created
init()
java.lang.IllegalThreadStateException
at java.lang.ThreadGroup.add(ThreadGroup.java:846)
at java.lang.Thread.start(Thread.java:596)
at scala.actors.FJTaskRunnerGroup.signalNewTask(Unknown Source)
at scala.actors.FJTaskRunnerGroup.execute(Unknown Source)
at scala.actors.FJTaskScheduler2.execute(FJTaskScheduler2.scala:164)
at scala.actors.Scheduler$.execute(Scheduler.scala:91)
at scala.actors.Actor$class.start(Actor.scala:782)
at com.lafros.MyActor.start(ActorsApplet.scala:30)
at com.lafros.ActorsApplet.init(ActorsApplet.scala:13)
at sun.applet.AppletPanel.run(AppletPanel.java:424)
at java.lang.Thread.run(Thread.java:619)
2009/4/3 Trond Olsen <tolsen77@gmail.com>Updated my own code with a Exit() message for manual release of all the actors and the applet now exits properly with back-forward on history.
On Thu, Apr 2, 2009 at 5:58 PM, Rob Dickens <arctic.bob@googlemail.com> wrote:
Trond,
Okay will try maintaining a reference, and have the destroy() use it to tell the actor to exit().
Thanks,
Rob
2009/4/2 Trond Olsen <tolsen77@gmail.com>
I guess you'll have to manually reference all actors and do a cleanup when your applet exit or is there a simple "kill-switch" for them? I retried my applet with browsing back and forth and the old actors also responds when I communicate from Javascript.
On Thu, Apr 2, 2009 at 4:08 PM, Rob Dickens <arctic.bob@googlemail.com> wrote:Dear all,
I'm encountering a problem if I return to a web page containing an applet that's using actors.
For a demonstration, the following page has the applet links:
http://lafros.com/Misc/actors-applet
There is also a problem if I reload the page, although this appears to be confined to the JDK 1.5 browser plug-in.
If anyone has any ideas about how to fix this, please could they respond.
The following tickets have been created:
actors cannot tolerate page reloads in JDK 1.5 plug-in applets
https://lampsvn.epfl.ch/trac/scala/ticket/1688
actors cannot tolerate returning to JDK 1.5 or 1.6 plug-in applet pages
https://lampsvn.epfl.ch/trac/scala/ticket/1848
Thanks,
--
Rob, Lafros.com
Sun, 2009-04-05, 18:07
#6
Re: actors in applets: problem if return to the page
catch {I haven't really read this thread, but I'm guessing you want to swap those two cases around.
case exp: Exception => // error handling
case exp: java.lang.NullPointerException => // error handling
}
Mon, 2009-04-06, 04:17
#7
Re: actors in applets: problem if return to the page
That's just something I hacked onto the message loop. They are handled the same (just logged) in my code. The NullPointerException went uncatched so I just added it.
If there are any better way to add a "catch-em-all" of exceptions to the message loop I'd be interested in a solution.
On Sun, Apr 5, 2009 at 7:01 PM, Ricky Clarkson <ricky.clarkson@gmail.com> wrote:
If there are any better way to add a "catch-em-all" of exceptions to the message loop I'd be interested in a solution.
On Sun, Apr 5, 2009 at 7:01 PM, Ricky Clarkson <ricky.clarkson@gmail.com> wrote:
catch {I haven't really read this thread, but I'm guessing you want to swap those two cases around.
case exp: Exception => // error handling
case exp: java.lang.NullPointerException => // error handling
}
Mon, 2009-04-06, 04:57
#8
Re: actors in applets: problem if return to the page
Nevermind, it shouldn't matter.
On Mon, Apr 6, 2009 at 5:09 AM, Trond Olsen <tolsen77@gmail.com> wrote:
On Mon, Apr 6, 2009 at 5:09 AM, Trond Olsen <tolsen77@gmail.com> wrote:
That's just something I hacked onto the message loop. They are handled the same (just logged) in my code. The NullPointerException went uncatched so I just added it.
If there are any better way to add a "catch-em-all" of exceptions to the message loop I'd be interested in a solution.
On Sun, Apr 5, 2009 at 7:01 PM, Ricky Clarkson <ricky.clarkson@gmail.com> wrote:catch {I haven't really read this thread, but I'm guessing you want to swap those two cases around.
case exp: Exception => // error handling
case exp: java.lang.NullPointerException => // error handling
}
On Thu, Apr 2, 2009 at 4:08 PM, Rob Dickens <arctic.bob@googlemail.com> wrote: