Perl Driver
  1. Perl Driver
  2. PERL-78

Why does database_names fail with Can't locate object method "run_command" via package "MongoDB::Database"

    Details

    • Type: Question Question
    • Status: Closed Closed
    • Priority: Trivial - P5 Trivial - P5
    • Resolution: Fixed
    • Affects Version/s: 0.31
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Linux CentOS 5.2 64 bits
    • # Replies:
      1
    • Last comment by Customer:
      true

      Description

      I've just started to test mongoDB by using Perl. My first attempt fail when I try to return the available databases using this simple program:

      #!/usr/bin/perl

      use strict;
      use warnings;
      use MongoDB;

      my $conn = MongoDB::Connection->new();
      my(@dbs) = $conn->database_names;
      exit;

      This returns the following:
      Can't locate object method "run_command" via package "MongoDB::Database" at /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/MongoDB/Connection.pm line 567.
      at /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/MongoDB/Connection.pm line 567
      MongoDB::Connection::database_names('MongoDB::Connection=HASH(0xa884090)') called at mtest.pl line 8

      The mongoDB server is running and the output from the daemon is:

      1. mongod --dbpath /opt/mongoDB --noauth
        Fri Apr 16 13:51:15 Mongo DB : starting : pid = 16094 port = 27017 dbpath = /opt/mongoDB master = 0 slave = 0 64-bit
        Fri Apr 16 13:51:16 db version v1.4.1, pdfile version 4.5
        Fri Apr 16 13:51:16 git version: 5b29dec9707d50979c283057ca1b1572351eef9a
        Fri Apr 16 13:51:16 sys info: Linux domU-12-31-39-06-79-A1 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_41
        Fri Apr 16 13:51:16 waiting for connections on port 27017
        Fri Apr 16 13:51:16 web admin interface listening on port 28017
        Fri Apr 16 13:52:14 connection accepted from 127.0.0.1:46054 #1
        Fri Apr 16 13:52:36 end connection 127.0.0.1:46054
        Fri Apr 16 13:52:53 connection accepted from 127.0.0.1:46061 #2
        Fri Apr 16 13:52:58 end connection 127.0.0.1:46061
        Fri Apr 16 13:53:01 connection accepted from 127.0.0.1:46063 #3
        Fri Apr 16 13:53:48 end connection 127.0.0.1:46063
        Fri Apr 16 13:53:53 connection accepted from 127.0.0.1:46073 #4
        Fri Apr 16 14:05:58 end connection 127.0.0.1:46073
        Fri Apr 16 14:06:01 connection accepted from 127.0.0.1:50582 #5
        Fri Apr 16 14:06:01 end connection 127.0.0.1:50582
        Fri Apr 16 14:07:31 connection accepted from 127.0.0.1:50597 #6
        Fri Apr 16 14:07:31 end connection 127.0.0.1:50597
        Fri Apr 16 14:07:41 connection accepted from 127.0.0.1:50600 #7
        Fri Apr 16 14:07:41 end connection 127.0.0.1:50600

      I can use the interactive mongo shell:

      1. mongo
        MongoDB shell version: 1.4.1
        url: test
        connecting to: test
        type "help" for help
        > help
        HELP
        show dbs show database names
        show collections show collections in current database
        show users show users in current database
        show profile show most recent system.profile entries with time >= 1ms
        use <db name> set curent database to <db name>
        db.help() help on DB methods
        db.foo.help() help on collection methods
        db.foo.find() list objects in collection foo
        db.foo.find( { a : 1 }

        ) list objects in foo where a == 1
        it result of the last line evaluated; use to further iterate
        > show dbs
        admin
        local
        >

        Activity

        • Comments
        Hide
        Jonas Lindholm
        added a comment -

        Problem solved. I had an old package of DateTime. As soon I upgraded the package the MongoDB interface worked.

        Show
        Jonas Lindholm
        added a comment - Problem solved. I had an old package of DateTime. As soon I upgraded the package the MongoDB interface worked.

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since reply:
              4 years, 1 week, 6 days ago