List Info

Thread: Two Strange Catalyst/Apache Issues




Two Strange Catalyst/Apache Issues
user name
2007-05-24 18:47:35
I am baffled by both of these, and I don't (usually) baffle that easily. First, the background:

- Latest Catalyst, C::E::Apache, and all related modules
- Using SQLite from within DBIC for model storage

My application runs fine from the test-server scripts that catalyst.pl auto-generated. When I moved it to Apache (1.3.37) + mod_perl (1.30), initially I just installed the various components into Perl's default site_perl structure. The application loaded fine, but would not connect to the SQLite database. I tried having it in the same dir as the YAML config file, and I tried putting in a specific place and changing the setting in the config to have an absolute path. I also experimented with modes (up to and including 666) and user/group combinations (both on the ownership of the file and the running httpd processes). Nothing I've tried gets it to open the DB.

The second problem came when I tried to move the application to a dedicated directory (this is a small app for my company, and they're more likely to want it to live in its own world as opposed to being dropped into site_perl). Then things really went wacky. After adding the apropos directory to the search-path in a <Perl&gt; block, attempting to start the server yielded this mess:

Subroutine Bylines::Model:B::class redefined at /usr/lib/perl5/site_perl/5.8.5/DBIx/Class/Schema.pm line 415.
Subroutine Bylines::Model:B::source redefined at /usr/lib/perl5/site_perl/5.8.5/DBIx/Class/Schema.pm line 415.
Subroutine Bylines::Model:B::resultset redefined at /usr/lib/perl5/site_perl/5.8.5/DBIx/Class/Schema.pm line 415.
Subroutine Bylines::Model:B::Sources::ACCEPT_CONTEXT redefined at /usr/lib/perl5/site_perl/5.8.5/Catalyst/Model/DBIC/Schema.pm line 301.
Subroutine Bylines::Model:B::Users::ACCEPT_CONTEXT redefined at /usr/lib/perl5/site_perl/5.8.5/Catalyst/Model/DBIC/Schema.pm line 301.
Subroutine Bylines::Model:B::Statii::ACCEPT_CONTEXT redefined at /usr/lib/perl5/site_perl/5.8.5/Catalyst/Model/DBIC/Schema.pm line 301.
Syntax error on line 259 of /usr/local/apache/conf/httpd.conf:
Can't locate Bylines/Model/DB/Users.pm in INC (INC contains: ...

(No need to show the list of INC contents, it's a typical perl 5.8.X set of paths)

I have one model defined, Bylines::Model:B. It's an empty sub-class of Catalyst::Model:BIC::Schema. In the configuration, I have defined the schema_class setting for Model:B to be "Bylines:B". Bylines/DB.pm is a sub-class of DBIx::Class::Schema, and loads three classes: Bylines:B::{Sources,Statii,Users}. In the -Debug output that Catalyst produces, I see that it has correctly mapped these classes to the model:

.-----------------------------------------------------------------+----------.
| Class ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; | Type   ;  |
+-----------------------------------------------------------------+----------+
| Bylines::Controller::Admin   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ;  | instance |
| Bylines::Controller::Ajax &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; | instance |
| Bylines::Controller::Edit &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; | instance |
| Bylines::Controller::Review ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; | instance |
| Bylines::Controller::Root &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; | instance |
| Bylines::Model:B &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp;  | instance |
| Bylines::Model:B::Sources  ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ;  | class ; &nbsp; |
| Bylines::Model:B::Statii&nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; | class ; &nbsp; |
| Bylines::Model:B::Users&nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   | class ; &nbsp; |
| Bylines::View::TT&nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp;  | instance |
'-----------------------------------------------------------------+----------';

However, it seems to be then trying to explicitly load Bylines::Model:B::Users after that. If I remove Users from the mix, I get the same error message with regards to Statii.

Any help/suggestions/ideas most welcomed.

Randy
--
Randy J. Ray / randy.j.raygmail.com">randy.j.raygmail.com
Campbell, CA
Re: Two Strange Catalyst/Apache Issues
user name
2007-05-24 20:59:39
On 5/24/07, Randy J. Ray < randy.j.raygmail.com">randy.j.raygmail.com> wrote:

Subroutine Bylines::Model:B::class redefined at /usr/lib/perl5/site_perl/5.8.5/DBIx/Class/Schema.pm line 415.
Subroutine Bylines::Model:B::source redefined at /usr/lib/perl5/site_perl/5.8.5/DBIx/Class/Schema.pm line 415.
Subroutine Bylines::Model:B::resultset redefined at /usr/lib/perl5/site_perl/5.8.5/DBIx/Class/Schema.pm line 415.
Subroutine Bylines::Model:B::Sources::ACCEPT_CONTEXT redefined at /usr/lib/perl5/site_perl/5.8.5/Catalyst/Model/DBIC/Schema.pm line 301.
Subroutine Bylines::Model:B::Users::ACCEPT_CONTEXT redefined at /usr/lib/perl5/site_perl/5.8.5/Catalyst/Model/DBIC/Schema.pm line 301.
Subroutine Bylines::Model:B::Statii::ACCEPT_CONTEXT redefined at /usr/lib/perl5/site_perl/5.8.5/Catalyst/Model/DBIC/Schema.pm line 301.
Syntax error on line 259 of /usr/local/apache/conf/httpd.conf:


the above error eems to indicate a problem on line 259.  

probably should setup like this:
http://search.cpan.org/~agrundma/Catalyst-Engine-Apache-1.11/lib/Catalyst/Engine/Apache/MP13.pm


hth, John

Re: Two Strange Catalyst/Apache Issues
user name
2007-05-24 21:17:29
On 5/24/07, John Goulah < jgoulahgmail.com">jgoulahgmail.com> wrote:

the above error eems to indicate a problem on line 259.  

probably should setup like this:
http://search.cpan.org/~agrundma/Catalyst-Engine-Apache-1.11/lib/Catalyst/Engine/Apache/MP13.pm

Sorry, I should have also excerpted my Apache config:

&lt;Perl>
 &nbsp;  use lib qw(/.../bylines); # This block only matters when the app is outside the default Perl areas
&lt;/Perl>

PerlModule Bylines&nbsp; &nbsp; # This is line 259
<Location /bylines&gt;
 &nbsp;  SetHandler perl-script
 &nbsp;  PerlHandler Bylines
&lt;/Location>

The line that is reporting the error is the PerlModule line. And the code doesn't have any errors in it when it runs under the Catalyst testing environment. I believe that particular diagnostic line is due to the failed attempt to load Bylines::Model:B::Users.

Randy
--
Randy J. Ray / randy.j.raygmail.com">randy.j.raygmail.com
Campbell, CA
Re: Two Strange Catalyst/Apache Issues
user name
2007-05-24 21:26:06
On 5/24/07, Randy J. Ray < randy.j.raygmail.com">randy.j.raygmail.com> wrote:
On 5/24/07, John Goulah < jgoulahgmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">jgoulahgmail.com> wrote:

the above error eems to indicate a problem on line 259.  

probably should setup like this:
http://search.cpan.org/~agrundma/Catalyst-Engine-Apache-1.11/lib/Catalyst/Engine/Apache/MP13.pm

Sorry, I should have also excerpted my Apache config:

&lt;Perl>
 &nbsp;  use lib qw(/.../bylines); # This block only matters when the app is outside the default Perl areas
&lt;/Perl>

PerlModule Bylines&nbsp; &nbsp; # This is line 259
<Location /bylines&gt;
 &nbsp;  SetHandler perl-script
 &nbsp;  PerlHandler Bylines
&lt;/Location>


I&#39;m not sure , except that I was also having problems with various things until I set it up such as the example in the link I pasted above, which yours is not  setup ; like. ;  My suggestion is to use a virtual host entry in the apache config.

Thanks,
John


Re: Two Strange Catalyst/Apache Issues
country flaguser name
United Kingdom
2007-05-24 22:51:39
On Thu, May 24, 2007 at 07:17:29PM -0700, Randy J. Ray
wrote:
> <Perl>
>    use lib qw(/.../bylines); # This block only matters
when the app is
> outside the default Perl areas
> </Perl>
> 
> PerlModule Bylines    # This is line 259
> <Location /bylines>
>    SetHandler perl-script
>    PerlHandler Bylines
> </Location>
> 
> The line that is reporting the error is the PerlModule
line. And the code
> doesn't have any errors in it when it runs under the
Catalyst testing
> environment. I believe that particular diagnostic line
is due to the failed
> attempt to load Bylines::Model:B::Users
.

Ah, the grand "let's compile everything twice"
mod_perl-ism (it's joys like
this that moved me to FastCGI for most stuff .

Is PerlRequire any better?

-- 
      Matt S Trout       Need help with your Catalyst or
DBIx::Class project?
   Technical Director    Want a managed development or
deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at)
shadowcatsystems.co.uk for a quote
http://chainsawblues.vo
x.com/             http://www.shadowc
atsystems.co.uk/ 

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: Two Strange Catalyst/Apache Issues
user name
2007-05-24 23:47:48
On 5/24/07, Randy J. Ray <randy.j.raygmail.com> wrote:
> PerlModule Bylines    # This is line 259

This recommended way to do this in mod_perl is actually to
make a
separate startup.pl file that loads your modules, not to
list them in
httpd.conf.  Then you call it with PerlRequire.  You can
find
documentation and examples here:
http://modpe
rlbook.org/html/ch04_02.html

To try it with your setup, just make file called startup.pl
with this in it:
use Bylines;

and then call it from httpd.conf:
PerlRequire startup.pl

- Perrin

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: Two Strange Catalyst/Apache Issues
country flaguser name
United Kingdom
2007-05-25 05:00:27
> <Perl>
>     use lib qw(/.../bylines); # This block only matters
when the app is
> outside the default Perl areas
> </Perl>

Is that really what you have? ... probably is right, and you
are missing the 
lib of the end of the path?

We use:

<Perl>
    use lib qw(/path/to/CatProject/lib/);
</Perl>


Carl
 


_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: Two Strange Catalyst/Apache Issues
user name
2007-05-25 16:46:55
On 5/25/07, Carl Johnstone < catalystfadetoblack.me.uk">catalystfadetoblack.me.uk>; wrote:
> <Perl&gt;
>&nbsp; &nbsp;  use lib qw(/.../bylines); # This block only matters when the app is
> outside the default Perl areas
> </Perl&gt;

Is that really what you have? ... probably is right, and you are missing the
lib of the end of the path?

In this configuration, that is the directory that holds the start of the module hierarchy. Bylines.pm is there, as are the Model, View and Controller directories.

What continues to vex me, is that when I load the modules from one location, everything loads and runs fine (my db problem has magically gone away, even). But when I install them outside of the site_perl root, Catalyst tries to explicitly load Bylines::Model:B::Users, when :B::Users is a plugged-in class from DBIC, that was created from Bylines::Model:B being a subclass of Catalyst::Model:BIC::Schema and being configured with schema_class.

Randy
--
Randy J. Ray / randy.j.raygmail.com">randy.j.raygmail.com
Campbell, CA
[1-8]

about | contact  Other archives ( Real Estate discussion Medical topics )