Home:ALL Converter>Net::Server incompatible with MongoDB

Net::Server incompatible with MongoDB

Ask Time:2011-12-15T08:38:14         Author:Eric

Json Formatter

When I am running this code inside of a module that inherits from Net::Server, MongoDB doesn't seem to work:

use base qw(Net::Server);

When I call this code without that inheritance, it works fine.

Can't locate object method "run_command" via package "MongoDB::Database" at /usr/local/lib/perl5/MongoDB/Connection.pm line 519
MongoDB::Connection::_get_max_bson_size('MongoDB::Connection=HASH(0x9d48bc8)') called at /usr/local/lib/perl5/MongoDB/Connection.pm line 463
MongoDB::Connection::BUILD('MongoDB::Connection=HASH(0x9d48bc8)', 'HASH(0x9d48ba8)') called at /opt...

Here is the line that is failing:

$mongo_handle =
  MongoDB::Connection->new( 'host' => 'mongodb://' . $host . ':' . $port );

Author:Eric,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/8513719/netserver-incompatible-with-mongodb
yy