in reply to Re^3: passing shared blessed object part 2
in thread passing shared blessed object part 2

Interesting...if I add use threads::shared; to the MyFrame package I see the following:
Thread 1 terminated abnormally: Can't locate object method "blessed" v +ia package "Can't locate object method "update" via package "Class::MOP::Class:: +__ANON__:: SERIAL::2" at thread_test.pl line 115. " (perhaps you forgot to load "Can't locate object method "update" via + package " Class::MOP::Class::__ANON__::SERIAL::2" at thread_test.pl line 115. "?) at thread_test.pl line 118.
I'm at a complete loss

Replies are listed 'Best First'.
Re^5: passing shared blessed object part 2
by stvn (Monsignor) on Nov 25, 2009 at 04:23 UTC

    So let me explain this error for you since it is pretty darn confusing, and then I have a few more suggestions.

    Can't locate object method "blessed" via package "Can't locate object +method "update" via package "Class::MOP::Class::__ANON__::SERIAL::2" +at thread_test.pl line 115.

    To start with, "Class::MOP::Class::__ANON__::SERIAL::2" is the name Moose/Class::MOP will give to an anon class. Exactly how or why this anon class was created I don't know, you will need to dig into the guts of Net::Twitter for that. I suspect it was runtime role composition, it is the most common usage of anon-classes.

    So the next part is

    Can't locate object method "update" via package "Class::MOP::Class::__ +ANON__::SERIAL::2
    Which is just saying that it cannot find the "update" method on that anon-class. Which I suspect is from your code right here:
    my $result = $thread_hash{'twit'}->update('Hello, world!');
    which makes sense because we figured out earlier that %thread_hash is either not being shared properly or at the very least the value stored in the 'twit' key is not what you expect it to be.

    This then brings us back to where we started ...

    Can't locate object method "blessed" via package "Can't locate object +method "update" via package "Class::MOP::Class::__ANON__::SERIAL::2" +at thread_test.pl line 115.
    So here is looks like someone is attempting to call the "blessed" method on an error ($@). But that actually is not the case since I suspect this is actually caused by your code here:
    die $@ unless blessed $err && $err->isa('Net::Twitter::Error');
    and basically Perl is interpretting "blessed" as a method call since you have not actually imported the Scalar::Util::blessed method into your package. What makes this really confusing is that your error ($@) is actually a string ("Can't locate object method "update" via package "Class::MOP::Class::__ANON__::SERIAL::2") and since Perl classes are really just strings Perl is thinking that this string is a class name, when in fact it is just an error string.

    So, if we look at all that this, I would suggest you try a couple things.

    1. Make sure you are importing Scalar::Util::blessed into MyFrame since it is being called in there.
    2. Dump the value (using Data::Dumper) of $thread_hash{'twit'} to see what it actually is (the class name is not given you enough details)
    Post the results of this and we can see what we have.

    -stvn
Re^5: passing shared blessed object part 2
by BrowserUk (Patriarch) on Nov 24, 2009 at 19:57 UTC

    Hm. Seems like you'll need the services of a Moose/MOP guru, cos those error messages are very confused. Sorry I cannot help further. (Or even at all it seems:( )


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.