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

I'm about to shoot myself. Mod_perl is making my work near impossible.

At times, the script doesn't even run. It sends me a "Cannot find server" error. When it does leave something in the error log, its a list of modules that it can't find--modules that are a part of the OO program I am using full paths to in the <c>require</code>s. I've tried Apache::Reload, but that doesn't seem to help. I'm trying to get the "touch reload" thing to work, but now it refuses to send me anything other than "Cannot find server."

This is obnoxious. I can't believe other people go through this. There has got to be something obvious that I am missing that makes debugging != hell.

Save me!

Replies are listed 'Best First'.
Re: Working with mod_perl
by andye (Curate) on Jan 03, 2002 at 20:52 UTC
    Have a look at Debugging mod_perl. Might be something there that'll help.

    If that's no help, then post the script - there a few things that you just can't use with mod_perl, e.g. the __DATA__ filehandle, so someone here might be able to spot the problem for you.

    andy.

Re: Working with mod_perl
by Hero Zzyzzx (Curate) on Jan 03, 2002 at 20:52 UTC

    You may be better served to add your path to your modules with use lib '/path/to/modules';, this will add that path to @INC.

    Are you using a different version of perl other than what mod_perl was compiled with? If you've upgraded perl, you need to recompile mod_perl, too. Your paths will likely be different in your different perl versions.

    If you're using Apache::Registry to speed up existing scripts and have a perl version mismatch, you may be able to "use lib" to the old version of perl, or change your shebang line to reflect the perl install you want.

    Before we go too far down this path, do you have more than one version of perl installed on your server?

    -Any sufficiently advanced technology is
    indistinguishable from doubletalk.

Re: Working with mod_perl
by Stegalex (Chaplain) on Jan 03, 2002 at 21:12 UTC
    Which version of mod_perl are you working with? Go with 1.2.4 or better (if you know what's good for you).

    I like chicken.
Re: Working with mod_perl
by techy (Scribe) on Jan 03, 2002 at 23:01 UTC
    "Cannot find server." in Internet Explorer is often the equivelant of "Document contains no data" in Netscape (IE uses some pretty generic error messages). Basically, a header was sent, but no data followed. Posting a code snippet could really help to find the problem, otherwise, put debug prints out to a file in your code to make sure it is getting where you expect, both after the header is sent and after the first html is sent. You can also try sending a small snippet right after the header to validate that this is the case.

    Also, are you using Apache::PerlRun or Apache::Registry? With Apache::PerlRun, the script is reloaded each time, and the namespace is cleared - when you are using a "require", it will only do the require the first time, but the namespace is cleared between each request, so anything that isn't in a different package is lost. If this is an issue, try "use" instead of "require", and make sure that everything is in a package.

    Of course, all of this is just guesses without seeing the code. Once mod_perl was set up and running correctly, and our code ported, I have found it fairly easy to debug. If all else fails, make a simpler test script, and add to it until you can duplicate the issues.

    techy