[Error] Shared Object inside Schedule Job

40 views
Skip to first unread message

Frenda Rangga Aksara

unread,
Jul 3, 2011, 4:47:29 AM7/3/11
to red5in...@googlegroups.com
I try to update SO and send to client. But it shows error like this:
java.lang.IllegalMonitorStateException
        at java.lang.Object.notifyAll(Native Method)
        at org.red5.core.Application$1.execute(Application.java:142)
        at org.red5.server.scheduling.QuartzSchedulingServiceJob.execute(QuartzS
chedulingServiceJob.java:59)
        at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.j
ava:525)

and my code :
this.addScheduledJob(5000,new IScheduledJob() {
            @Override
            public void execute(ISchedulingService jobs0)
                    throws CloneNotSupportedException {
                System.out.println(sendList);
                try{
                    so.setAttribute("thread", sendList);
                    so.notifyAll();
                }catch (Exception e) {
                    e.printStackTrace();
                }
    
            }
        });

it shows error like that when so.notifyAll();
Have anyone ever crush something like that?

thanks in advance

Cristian Rusu

unread,
Jul 3, 2011, 5:53:53 AM7/3/11
to red5in...@googlegroups.com
Google:
In order to use notify* or wait, the current thread needs to be the owner of the
lock on the object, in this case the 'this' object.  Either declare the function
as 'synchronized' or create a synchronized block around the notify.

---------------------------------------------------------------
Cristian Rusu
Web Developement & Electronic Publishing

======
Crilance.com
Crilance.blogspot.com

Frenda Rangga Aksara

unread,
Jul 3, 2011, 6:18:26 AM7/3/11
to red5in...@googlegroups.com
hi, I have did what you have suggested, like this :

try{
                    so.setAttribute("thread", sendList);
                    synchronized (so) {

                        so.notifyAll();
                    }
                }catch (Exception e) {
                    e.printStackTrace();
                }

Correct me if I'm wrong.
it didn't show error, but my SO didn't updated or it didn't send to my client.
any idea?

thanks for replay

Cristian Rusu

unread,
Jul 3, 2011, 10:01:03 AM7/3/11
to red5in...@googlegroups.com
Usually I don't call any notification
Make sure you actually create a listener o flash
When I set attribute on SO, it automatically goes to all connected clients as updated.


---------------------------------------------------------------
Cristian Rusu
Web Developement & Electronic Publishing

======
Crilance.com
Crilance.blogspot.com



Frenda Rangga Aksara

unread,
Jul 3, 2011, 10:27:59 AM7/3/11
to red5in...@googlegroups.com
Yeah, when I didn't use ScheduleJob, it's run correctly. I wonder it because the scheduleJob, but I still don't know.

my listener client like this :
public function onCreationComplete(event:FlexEvent) : void {
                // setup connection code
                connection = new NetConnection();
                connection.addEventListener(NetStatusEvent.NET_STATUS, onConnectionNetStatus);
                connection.connect("rtmp:/Red5Trhread");
                connection.client = this;
                shared = SharedObject.getRemote("thread", connection.uri, false);
                shared.client = this;
                shared.connect(connection);
                shared.addEventListener(SyncEvent.SYNC, receiveVariable);
            }

public function receiveVariable(e:SyncEvent):void{
                Alert.show(shared.data.thread.toSting()+"test");
                var temp:String = shared.data.thread.toSting();
                myAC2 = temp.split(",");   
                arrayOfObject = myAC2.map(toObject);
                list1.dataProvider = arrayOfObject;       

Andy Shaules

unread,
Jul 3, 2011, 10:32:20 AM7/3/11
to red5in...@googlegroups.com
Your client code is all wrong.

You cant do all that in one single function and your stuff is out of order.

public function onCreationComplete(event:FlexEvent) : void {
// setup connection code
connection = new NetConnection();
connection.addEventListener(NetStatusEvent.NET_STATUS,
onConnectionNetStatus);

connection.client = this;
connection.connect("rtmp:/Red5Trhread");
}


public function onConnectionNetStatus(nse:NetStatusEvent){
if(nse.info.code=="NetConnectionConnectSuccess")
{ shared = SharedObject.getRemote("thread", connection.uri, false);
shared.client = this;
shared.addEventListener(SyncEvent.SYNC, receiveVariable);
shared.connect(connection);

Cristian Rusu

unread,
Jul 3, 2011, 11:13:08 AM7/3/11
to red5in...@googlegroups.com
Also is this really correct?

"rtmp:/Red5Trhread

I can see a typo there...?

---------------------------------------------------------------
Cristian Rusu
Web Developement & Electronic Publishing

======
Crilance.com
Crilance.blogspot.com



Frenda Rangga Aksara

unread,
Jul 3, 2011, 11:16:02 AM7/3/11
to red5in...@googlegroups.com
@Cristian : it's correct, I make a typo when create project :D
@Andy: I'll try it, bro. thanks

Frenda Rangga Aksara

unread,
Jul 3, 2011, 11:30:50 AM7/3/11
to red5in...@googlegroups.com
@andy: I have did what you have said. Move sharedObject definition at onConnectionNetStatus. But, it's still same problem. How about Sync.Event, is it true?
sorry, i don't have any idea about this problem.

Frenda Rangga Aksara

unread,
Jul 5, 2011, 1:22:58 AM7/5/11
to red5in...@googlegroups.com
hmm, I can't solved it yet.

Frenda Rangga Aksara

unread,
Jul 7, 2011, 8:27:57 PM7/7/11
to red5in...@googlegroups.com
Hi Cris and Andy. Finally I make it, the problem is at my client function when receiving sharedobject data. I make a typo, because the compiler didn't notice it.
Thanks to you all.

Mondain

unread,
Jul 8, 2011, 9:32:39 AM7/8/11
to red5in...@googlegroups.com
The method you tried to use is not for notifying shared object subscribers, it is a base Object method and must be used in a synchronized block. If you want to know more about it, read this post: http://www.java-samples.com/showtutorial.php?tutorialid=306

Paul

Frenda Rangga Aksara

unread,
Jul 9, 2011, 12:29:47 AM7/9/11
to red5in...@googlegroups.com
Hi, mondain. So, in your opinion. What must i do to notify  the change of shared object ?

Cristian Rusu

unread,
Jul 9, 2011, 7:32:35 AM7/9/11
to red5in...@googlegroups.com
Nothing, it should update connected clients automatically


---------------------------------------------------------------
Cristian Rusu
Web Developement & Electronic Publishing

======
Crilance.com
Crilance.blogspot.com



Reply all
Reply to author
Forward
0 new messages