Meteor method not found


#1

I have a method that when called gives me the error message “Method not found” even though the method does exist and the method is actually called and does what it’s supposed to do.

The method exists in code accessible to both the client and the server.

I’m getting the same error whether I call the method from the client or from another server method (and in each case, the method does what it’s supposed to do!)

This method has been working for over a year and I have no idea what I’ve done to the project to stop it from working. I haven’t been messing around with the code too much.

Any ideas?

Here’s the error stack:
I20150311-14:58:49.402(0)? Exception in delivering result of invoking ‘joinLeague’: Error: Error adding user to league: Error: Method not found [404] [100]
I20150311-14:58:49.402(0)? at app/lib/collections/leagues.js:507:17
I20150311-14:58:49.402(0)? at runWithEnvironment (packages/meteor/dynamics_nodejs.js:108:1)
I20150311-14:58:49.402(0)? at packages/meteor/dynamics_nodejs.js:121:1
I20150311-14:58:49.402(0)? at [object Object]..extend.apply (packages/ddp/livedata_server.js:1528:1)
I20150311-14:58:49.402(0)? at [object Object].
.extend.call (packages/ddp/livedata_server.js:1455:1)
I20150311-14:58:49.403(0)? at app/lib/collections/leagues.js:505:14
I20150311-14:58:49.403(0)? at wrappedCallbackForParsingMongoValidationErrors (packages/aldeed:collection2/collection2.js:391:1)
I20150311-14:58:49.403(0)? at wrappedCallback (packages/mongo/collection.js:528:1)
I20150311-14:58:49.403(0)? at runWithEnvironment (packages/meteor/dynamics_nodejs.js:108:1)
I20150311-14:58:49.403(0)? at packages/meteor/dynamics_nodejs.js:121:1

Also, running the following code in the browser console does work:
Meteor.call(‘joinLeague’, …);


#2

Looks like the error is within the method, not the method itself. Can you please post your method code?
Also, do you get an error server-side?


#3

This is one server side method calling another server side method. The code looks something like this:

Meteor.methods({
  joinLeague: function (leagueId, teamName, password, autoPick) {
    check(leagueId, String);
    check(teamName, String);
    ...
  },

  createLeague: function (options) {
    ...
    var league = {
      name: leagueName,
      ...
    };

    console.log('valid league');

    return Leagues.insert(league, function (err, leagueId) {
      if (err) {
        throw new Meteor.Error(100, 'Error creating league: ' + err);
      }

      // IMPORTANT PART
      Meteor.call('joinLeague', leagueId, creatorsTeamName, password, true, function (error, result) {
        if (error) {
          throw new Meteor.Error(100, 'Error adding user to league: ' + error);
        }

        console.log('Successfully created league and added creator to league.');
      });

    });
  },