Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Catalyst by the Book- The Train Wreck Continues

by roho (Chancellor)
on Mar 19, 2010 at 00:49 UTC ( #829515=perlquestion: print w/replies, xml ) Need Help??

roho has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks,
I have been trying to work my way through Jonathan Rockway's book "Catalyst: Accelerating Perl Web Application Development" and it has been a most painful experience. The database example in Chapter 2 will not render the TT template (see previous post: 828813). I spent a week trying to track down the error and finally gave up and moved on to Chapter 3. The "AddressBook" example generates the following error messages:

C:\AddressBook>perl script\addressbook_server.pl -d Couldn't instantiate component "AddressBook::Model::AddressDB", Couldn't load class (AddressBook::Schema::AddressDB) because: DBIx::Class::Schema::throw_exception(): DBIx::Class::Row::throw_except +ion():
Can't locate AddressBook/Schema/AddressDB/People.pm in @INC
(@INC contains: C:/AddressBook/script/../lib C:/Perl/site/lib C:/Perl/ +lib .) at C:/Perl/site/lib/Class/C3/Componentised.pm line 135.

The "C:/AddressBook/script/../lib" entry in @INC is the top level path for the directory where "People.pm" resides, but the app cannot locate the module within the code structure generated by Catalyst.

I'm beginning to think that so much has changed since the book was written in 2007 that none of the examples may be valid any longer. This is definitely NOT the best environment for someone trying to learn Catalyst. I have heard so many glowing comments about how great Catalyst is and how easy it makes web app development, but all that is starting to grow dim in the face of errors that are buried deep in Catalyst (or DBIx::Class or Template Toolkit).

I am posting the above error messages in hopes that someone who has trodden this way before may have a clue how to resolve them. I really want to learn Catalyst, but maybe this is not the best route to go.

Thank you for any insight you can provide.

"Its not how hard you work, its how much you get done."

Replies are listed 'Best First'.
Re: Catalyst by the Book- The Train Wreck Continues
by stonecolddevin (Parson) on Mar 19, 2010 at 03:20 UTC

    Do not go off of jrockway's book. It's out of date and we've written a new one. Use that. Also, ikegami nailed it with an improper location in your @INC.

    mtfnpy

        ++. There was a pretty long period of instability between those releases and the current code base which has finally become smooth again. Any number of module version issues in plugins, Moose, parent classes, and more cause problems in between. The new book is generally better and Cat 5.8 is different enough from 5.7 that it's probably what you (the OP) should be reading.

        > switch to a release from the same time period

        or alternatively someone interested in selling the book should upload erratas and new code-examples to it's webpage...(?)

        UPDATE: Or at least a warning about the applicable versions of catalyst...

        Cheers Rolf

Re: Catalyst by the Book- The Train Wreck Continues
by ikegami (Pope) on Mar 19, 2010 at 01:32 UTC

    The "C:/AddressBook/script/../lib" entry in @INC is the top level path for the directory where "People.pm" resides

    It's looking for AddressBook/Schema/AddressDB/People.pm, not People.pm. The file should be located at C:/AddressBook/lib/AddressBook/Schema/AddressDB/People.pm, not C:/AddressBook/lib/People.pm.

Re: Catalyst by the Book- The Train Wreck Continues
by ww (Archbishop) on Mar 19, 2010 at 01:03 UTC
    Not exactly an insight, but perhaps you need a different book.

    Check dhoss' homepage to see if any of his listings might be a starting point
    ... and you may wish to use Super Search for additional material.

      Thanks ww, I'll check them out.

      "Its not how hard you work, its how much you get done."

Re: Catalyst by the Book- The Train Wreck Continues
by roho (Chancellor) on Mar 19, 2010 at 17:29 UTC
    I started with a clean slate, just to verify that Catalyst is generating runnable code out of the box (and it is), as in the following steps:
    • C:\ catalyst.pl AddressBook
    • C:\ cd AddressBook
    • C:\AddressBook\ sqlite3 database < create_database.sql
    • C:\AddressBook\ (Verified SQLite database created properly)
    • C:\AddressBook\ perl script\addressbook_create.pl view HTML TTSite
    • C:\AddressBook\ perl script\addressbook_create.pl model AddressDB DBIC::Schema AddressBook::Schema::AddressDB create=static dbi:SQLite:database
    • C:\AddressBook\ perl script\addressbook_server.pl
    • C:\AddressBook\ "C:\Program Files (x86)\Internet Explorer\iexplore.exe" http://localhost:3000/

    The default Catalyst page is displayed in the web browser, so it must be something in the book's modification instructions that's messing things up, and right now I have neither the time nor the patience to debug the book while trying to learn Catalyst. It looks like it's time for a new learning source. (sigh!)

    Thanks to all for your comments and suggestions.

    "Its not how hard you work, its how much you get done."

      This was bugging me, so I created a fresh Catalyst skeleton and tested after applying each mod in the book. The problem was simply errors in the text of the book, not Catalyst version differences, etc. An errate list for this book is definitely in order if people are to use it effectively.

      FWIW, the invalid text causing all my module location error messages is on p. 22 of the book, as shown in the "before" and "after" lines below:

      Before:
      __PACKAGE__->has_many(
      addresses => 'AddressBook::Schema::AddressDB::Addresses',

      After:
      __PACKAGE__->has_many(
      addresses => 'AddressBook::Schema::AddressDB::Result::Address',



      Before:
      __PACKAGE__->belongs_to(
      person => 'AddressBook::Schema::AddressDB::People',

      After:
      __PACKAGE__->belongs_to(
      person => 'AddressBook::Schema::AddressDB::Result::People',

      "Its not how hard you work, its how much you get done."

        I stand corrected. This problem _is_ related to versions. After locating the book's errata at http://wiki.catalystframework.org/wiki/thebookerrata, one of the entries pointed out that version 0.22 and later of "Catalyst::Model::DBIC::Schema" add '::Result' to the generated classes. I wish I had found this errata page earlier. It would have saved much time and frustration.

        "Its not how hard you work, its how much you get done."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://829515]
Approved by ww
Front-paged by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2020-02-18 09:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (75 votes). Check out past polls.

    Notices?