Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

mod_perl and BerkeleyDB

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


geoffeg at sloth

Jun 25, 2000, 7:33 PM

Post #1 of 3 (269 views)
Permalink
mod_perl and BerkeleyDB

I've been trying to get BerkeleyDB and mod_perl to work together for a
web database. I'm using BerkeleyDB version 3.1.14 on a RedHat 6.1 based
system with a stock kernel under apache 1.3.12 and mod_perl 1.21. I wrote
a simple script to open a berkeley database, read all variables then write
one.. When running under mod_perl I get the following error from apache:

[Sun Jun 25 20:38:28 2000] [error] Can't locate object method "TIEHASH"
via package "BerkeleyDB::Hash" at /home/httpd/cgi-bin/dbtest.pl line 9.

but when I run the same script (with mod_perl stuff commented out) under
the shell it works fine. The script is included below. I've tried running
the scipt as nobody to see if there is a permissions problem but the shell
version works fine. I'm at a complete loss as to what the problem might
be, any help would be *greatly* appreciated..

--- Begining of code ---

#!/usr/bin/perl -w
use Apache::Constants; # Commented out for shell version
use BerkeleyDB;

my $r = Apache->request; # Commented out for shell version
$r->content_type("text/html"); # Commented out for shell version
$r->send_http_header(); # Commented out for shell version

my $filename = "/tmp/testdb";
tie %h, "BerkeleyDB::Hash",
-Filename => $filename,
-Flags => DB_CREATE
or die "Can't open $filename: $! $BerkeleyDB::Error\n";

while (($k, $v) = each %h) {
print "$k -> $v\n";
}
$h{"apple"} = "red";
untie %h

--- End of code ---

Thanks in advance,
GeoffEG

--
Geoffrey Gallaway || This may seem a bit weird, but that's okay, because it
geoffeg [at] sloth || is weird.
D e v o r z h u n || -- Tom Christiansen


khera at kciLink

Jun 25, 2000, 7:51 PM

Post #2 of 3 (233 views)
Permalink
Re: mod_perl and BerkeleyDB [In reply to]

Are you sure that your mod_perl and command-line perl are the same
versions? That is, is your mod_perl built after your latest upgrade
to perl, and is there only one version of perl on your system?


perrin at primenet

Jun 25, 2000, 9:21 PM

Post #3 of 3 (259 views)
Permalink
Re: mod_perl and BerkeleyDB [In reply to]

Geoffrey Gallaway wrote:
>
> I've been trying to get BerkeleyDB and mod_perl to work together for a
> web database. I'm using BerkeleyDB version 3.1.14 on a RedHat 6.1 based
> system with a stock kernel under apache 1.3.12 and mod_perl 1.21. I wrote
> a simple script to open a berkeley database, read all variables then write
> one.. When running under mod_perl I get the following error from apache:
>
> [Sun Jun 25 20:38:28 2000] [error] Can't locate object method "TIEHASH"
> via package "BerkeleyDB::Hash" at /home/httpd/cgi-bin/dbtest.pl line 9.

Did BerkeleyDB pass all tests? Are you certain your perl doesn't have a
different libdb linked in? (Use ldd on it to find out.) RedHat comes
with an older libdb installed, so it can be tricky to make sure you're
egtting the right one. I had to edit config.in from the BerkeleyDB
distribution before it worked for me.

The fact that this works under command-line scripts does point to your
mod_perl being linked to a different version of perl, as Vivek pointed
out.

- Perrin

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.