in reply to Re^2: Class::MOP won't load a class!!
in thread Class::MOP won't load a class!!

does is a sugar function exported by Moose. It's job is to check if a given Moose class 'does' a role.

Yes, I know, I am the (original) author of Moose and Class::MOP :)

And actually, does is not part of the exported sugar, it is a method of Moose::Object.

I am more inclined to believe that the class hasn't been loaded because in the output of t/Parser.t, I don't see the line finished loading plugin.

Yes, but the failure is saying there is no does method, and you don't call the does until after that line would be printed. There is no reason why Class::MOP::is_class_loaded would be calling does as does is a Moose thing and not a Class::MOP thing. Perhaps you are calling or loading an older version of the Admin_server::Parser module?

Admin_server::Parser::Plugin::FeedHandler has four functions - none of which is does. I could list them out but not sure if they are relevant to the discussion.

Perhaps it wouldn't be helpful, but it wouldn't hurt either. It also might be good to let us know the version of Moose/Class::MOP your running too.

For what its worth, it works on my machine when I reproduced your code and setup.

-stvn

Replies are listed 'Best First'.
Re^4: Class::MOP won't load a class!!
by MarkovChain (Sexton) on Oct 07, 2009 at 15:36 UTC

    Hi Steven,

    Whoa!! Respect Sir!!

    I must apologize for my delay in reply. I just had a kid and had to take care of the little doodle and mommy.

    Ok so here are the point(s).

    1. According to http://search.cpan.org/~drolsky/Moose-0.92/lib/Moose/Object.pm, This class is the default base class for all Moose-using classes. When you use Moose in this class, your class will inherit from this class.. And my FeedHandler.pm starts off with:
      19 package Admin_server::Parser::Plugin::Feedhandler; 20 use MooseX::FollowPBP; 21 use Moose; 22 23 with 'Admin_server::Interface::ParserInterface';
      So even does should be available anyway.
    2. I have for functions in the module. They are:

      is_yours()

      tell_status()

      tell_script_names()

      tell_instance_info()

    3. I am currently using version 0.92 of Class::MOP.

    Thank You,

    - Markov
Re^4: Class::MOP won't load a class!!
by MarkovChain (Sexton) on Oct 07, 2009 at 20:41 UTC

    So I thought I would print out the symbol table in %Admin_server::Parser,

    75 print "Plugin $plugin is loaded indeed.\n" 76 if ( Class::MOP::is_class_loaded($plugin) ); 77 78 #===================================== 79 # Let's print out the symbol table to check 80 # whether the plugins loads up. 81 #===================================== + 82 83 print '-'x80, "\n"; 84 print 'Printing out the symbol table....', "\n"; + 85 print '-'x80, "\n"; 86 foreach my $key ( sort {$a cmp $b} keys %Admin_server::Pa +rser:: ) { 87 print $key, "\n"; + 88 }
    and this is what i get...
    $prove -lv t/Parser.t t/Parser.t .. 1..4 ok 1 - use Admin_server::Parser; ok 2 - Admin_server::Parser can be instantiated. ok 3 - Instantiated object is of type Admin_server::Parser Found plugins: Admin_server::Parser::Plugin::FeedHandler Loading plugin Admin_server::Parser::Plugin::FeedHandler finished loading Admin_server::Parser::Plugin::FeedHandler ---------------------------------------------------------------------- +---------- Printing out the symbol table.... ---------------------------------------------------------------------- +---------- BEGIN BUILD BUILDARGS DEMOLISH DEMOLISHALL DESTROY ISA ParserInterface Plugin:: _build_plugins a b blessed can clear_plugins confess get_plugins has_plugins import isa meta new tell_app_name tell_app_status Can't locate object method "does" via package "Admin_server::Parser::P +lugin::FeedHandler" (perhaps you forgot to load "Admin_server::Parser +::Plugin::FeedHandler"?) at /Volumes/UserData/Users/dattanik/Programs +/Perl/Work_area/Admin_server/lib/Admin_server/Parser.pm line 91. # Looks like you planned 4 tests but ran 3. # Looks like your test exited with 255 just after 3.

    So as you can see, there is no FeedHandler sitting there..... I am lost :(

      So as you can see, there is no FeedHandler sitting there..... I am lost :(

      Have you tried loading FeedHandler by hand? Perhaps there is an error in the module and for some reason that error is getting swallowed.

      Congrats on the baby btw!

      -stvn

        Hi Steven,

        Thank you for the good wishes.

        I've been testing from inside out. So I did test the loading first prior to checking the translator.

        $perl use Admin_server::Parser; use Admin_server::Parser::Plugin::Feedhandler;

        I don't get any errors.

        Also,

        $prove -lv t/Plugin/FeedHandler.t t/Plugin/FeedHandler.t .. 1..34 ok 1 - use Admin_server::Parser::Plugin::FeedHandler; ok 2 - Admin_server::Parser::Plugin::Feedhandler can be instantiated. ok 3 - Instantiated object is of type Admin_server::Parser::Plugin::Fe +edhandler. ok 4 - Conforms to canonized plugin interface - does Admin_server::Int +erface::ParserInterface. ok 5 - Feed handler application correctly identified. ok 6 - tell_instance_info succesfully called. ok 7 - tell_instance_info returns a hash reference. ok 8 - tell_instance_info return hash has a key of 'instance_name'. ok 9 - Instance name correctly extracted from first line of log4x data +. ok 10 - Instance name negative test successful. ok 11 - Instance name negative test successful. ok 12 - tell_script_names successfully called. ok 13 - tell_script_names returns a hash. ok 14 - The tell_script_names return hash has a key of start_script. ok 15 - The tell_script_names return hash has a key of stop_script. ok 16 - Start script name correctly extracted from first line of log4x + data. ok 17 - Stop script name correctly extracted from first line of log4x +data. ok 18 - Start script name negative test successful - (with erroneous d +ata). ok 19 - Stop script name negative test successful - (with erroneous da +ta). ok 20 - Start script name negative test successful - (with undef data) +. ok 21 - Stop script name negative test successful - (with undef data). ok 22 - tell_status successfully called with a log4x line not having a +n error. ok 23 - tell_status returns a hash. ok 24 - tell_status correctly diagnoses feed handler as up. ok 25 - tell_status return hash doesn't have the app_down key when app + is up. ok 26 - tell_status return hash doesn't have the app_unknown key when +app is up. ok 27 - tell_status successfully called with a log4x line having an er +ror. ok 28 - The tell_status correctly diagnoses feed handler as down. ok 29 - tell_status return hash doesn't have the app_up key when app i +s down. ok 30 - tell_status return hash doesn't have the app_unknown key when +app is down. ok 31 - tell_status successfully called with a undef value. ok 32 - The tell_status correctly diagnoses feed handler status as unk +nown. ok 33 - tell_status return hash doesn't have the app_up key when app i +s unknown. ok 34 - tell_status return hash doesn't have the app_unknown key when +app is unknown. ok All tests successful. Files=1, Tests=34, 1 wallclock secs ( 0.03 usr 0.01 sys + 0.22 cusr + 0.02 csys = 0.28 CPU) Result: PASS

      AARGH.... There see does is sitting there fine and dandy under Moose::Object and my class does a  use Moose;....?? Cut me some slack here Moosy!!

      $prove -lv t/Parser.t t/Parser.t .. 1..3 ok 1 - use Admin_server::Parser; ok 2 - Admin_server::Parser can be instantiated. ok 3 - Instantiated object is of type Admin_server::Parser Found plugins: Admin_server::Parser::Plugin::FeedHandler Loading plugin Admin_server::Parser::Plugin::FeedHandler finished loading Admin_server::Parser::Plugin::FeedHandler ---------------------------------------------------------------------- +---------- Printing out the symbol table for %Admin_server::Parser:: .... ---------------------------------------------------------------------- +---------- BEGIN BUILD BUILDARGS DEMOLISH DEMOLISHALL DESTROY ISA ParserInterface Plugin:: _build_plugins a b blessed can clear_plugins confess get_plugins has_plugins import isa meta new tell_app_name tell_app_status ---------------------------------------------------------------------- +---------- Printing out the symbol table for %Class::MOP .... ---------------------------------------------------------------------- +---------- AUTHORITY Attribute:: BEGIN Class:: HAVE_ISAREV IS_RUNNING_ON_5_10 Instance:: Method:: Module:: Object:: Package:: VERSION XS_VERSION __ANON__ _class_to_pmfile _is_valid_class_name _try_load_one_class blessed bootstrap check_package_cache_flag class_of confess does_metaclass_exist get_all_metaclass_instances get_all_metaclass_names get_all_metaclasses get_code_info get_metaclass_by_name import in_global_destruction is_class_loaded load_class load_first_existing_class reftype remove_metaclass_by_name store_metaclass_by_name subname weaken weaken_metaclass ---------------------------------------------------------------------- +---------- Printing out the symbol table for %Admin_server::Parser::Plugin::Feedh +andler:: .... ---------------------------------------------------------------------- +---------- BEGIN BUILD BUILDARGS DEMOLISH DEMOLISHALL DESTROY ISA blessed can confess is_yours isa meta new tell_instance_info tell_script_names tell_status ---------------------------------------------------------------------- +---------- Printing out the symbol table for %Moose::Object:: .... ---------------------------------------------------------------------- +---------- AUTHORITY BEGIN BUILD BUILDALL BUILDARGS DEMOLISH DEMOLISHALL DESTROY DOES ISA VERSION __mx_is_compiled can does dump import in_global_destruction meta new ---------------------------------------------------------------------- +---------- Done... ---------------------------------------------------------------------- +---------- Can't locate object method "does" via package "Admin_server::Parser::P +lugin::FeedHandler" (perhaps you forgot to load "Admin_server::Parser +::Plugin::FeedHandler"?) at /Volumes/UserData/Users/dattanik/Programs +/Perl/Work_area/Admin_server/lib/Admin_server/Parser.pm line 114. # Looks like your test exited with 255 just after 3. Dubious, test returned 255 (wstat 65280, 0xff00) All 3 subtests passed Test Summary Report ------------------- t/Parser.t (Wstat: 65280 Tests: 3 Failed: 0) Non-zero exit status: 255 Files=1, Tests=3, 0 wallclock secs ( 0.04 usr 0.01 sys + 0.23 cusr + 0.02 csys = 0.30 CPU) Result: FAIL

      Sorry just venting out.....

        Try printing out the @ISA of Admin_server::Parser::Plugin::FeedHandler, it should have Moose::Object in it. Simplest way to do that is

        print join ", " => @{ Admin_server::Parser::Plugin::FeedHandler->meta- +>superclasses }
        I am also a little puzzled as to why Admin_server::Parser:: and Admin_server::Parser::Plugin::Feedhandler:: have BUILD, BUILDARGS, DEMOLISH and DEMOLISHALL defined in their symbol tables, those are methods in Moose::Object.

        -stvn

        Hi Steven,

        Yeah Moose::Object shows up.

        I modified the test file for Admin_server::Parser::Plugin::Feedhandler as follows:

        =========================================

        #---------------------------------------------------------- # These are to test the ISA array. #---------------------------------------------------------- print "="x79 . "\n"; print STDOUT join ", ", $fh->meta()->superclasses(); print "\n"; print "="x79 . "\n"; print STDOUT join ", ", sort $fh->meta()->get_all_method_names(); print "\n"; print "="x79 . "\n";

        =========================================

        Upon proving it, I got the following results:

        =========================================

        $prove -lv t/Plugin/FeedHandler.t t/Plugin/FeedHandler.t .. 1..34 ok 1 - use Admin_server::Parser::Plugin::FeedHandler; ok 2 - Admin_server::Parser::Plugin::Feedhandler can be instantiated. ok 3 - Instantiated object is of type Admin_server::Parser::Plugin::Fe +edhandler. ok 4 - Conforms to canonized plugin interface - does Admin_server::Int +erface::ParserInterface. ok 5 - Feed handler application correctly identified. ok 6 - tell_instance_info succesfully called. ok 7 - tell_instance_info returns a hash reference. ok 8 - tell_instance_info return hash has a key of 'instance_name'. ok 9 - Instance name correctly extracted from first line of log4x data +. ok 10 - Instance name negative test successful. ok 11 - Instance name negative test successful. ok 12 - tell_script_names successfully called. ok 13 - tell_script_names returns a hash. ok 14 - The tell_script_names return hash has a key of start_script. ok 15 - The tell_script_names return hash has a key of stop_script. ok 16 - Start script name correctly extracted from first line of log4x + data. ok 17 - Stop script name correctly extracted from first line of log4x +data. ok 18 - Start script name negative test successful - (with erroneous d +ata). ok 19 - Stop script name negative test successful - (with erroneous da +ta). ok 20 - Start script name negative test successful - (with undef data) +. ok 21 - Stop script name negative test successful - (with undef data). ok 22 - tell_status successfully called with a log4x line not having a +n error. ok 23 - tell_status returns a hash. ok 24 - tell_status correctly diagnoses feed handler as up. ok 25 - tell_status return hash doesn't have the app_down key when app + is up. ok 26 - tell_status return hash doesn't have the app_unknown key when +app is up. ok 27 - tell_status successfully called with a log4x line having an er +ror. ok 28 - The tell_status correctly diagnoses feed handler as down. ok 29 - tell_status return hash doesn't have the app_up key when app i +s down. ok 30 - tell_status return hash doesn't have the app_unknown key when +app is down. ok 31 - tell_status successfully called with a undef value. ok 32 - The tell_status correctly diagnoses feed handler status as unk +nown. ok 33 - tell_status return hash doesn't have the app_up key when app i +s unknown. ok 34 - tell_status return hash doesn't have the app_unknown key when +app is unknown. =============================================================== Moose::Object =============================================================== BUILDALL, BUILDARGS, DEMOLISHALL, DESTROY, DOES, does, dump, is_yours, + meta, new, tell_instance_info, tell_script_names, tell_status =============================================================== ok All tests successful. Files=1, Tests=34, 0 wallclock secs ( 0.03 usr 0.01 sys + 0.22 cusr + 0.02 csys = 0.28 CPU) Result: PASS

        =========================================

        So the good news is that Moose::Object shows up there. does shows up too!!