gen_mod:start_module:78 Problem starting the module my_module for host <<"localhost">>

Hi,

I run a small private group of users on an XMPP server and recently I have been wanting to write a custom module that that will timestamp all messages. I figure something like an ejabberd hook using filter_packets would work perfect (adding something like this to the message body 2014-04-11 12:30:00 and then parse it on the client side).

As I have not written a custom module before and being at an low intermediate level with Erlang I decided to go for the basics - following Jack Moffits mod_sunshine.erl example as well as Anders Conbere's examples.

I am running ejabberd-13.12 community edition on Ubuntu LTS 12.04. For the life of me I can not get mod_sunshine to work or even just a basic skeletal module to work (see below mod_test.erl).

I compile to a beam file, I edit the ejabberd.cfg file (in ejabberd-13.12 it is ejabberd.yml). I restart and get the following error:

gen_mod:start_module:78 Problem starting the module mod_sunshine for
host <<"xmpp1.xxxxx.com">>
options: []
error: undef
[{ejabberd_logger,info_msg,[mod_sunshine,13,"mod_sunshine starting",[]],[]},
{mod_sunshine,start,2,[{file,"src/mod_sunshine.erl"},{line,13}]},
{gen_mod,start_module,3,[{file,"src/gen_mod.erl"},{line,70}]},
{lists,foreach,2,[{file,"lists.erl"},{line,1323}]},
{ejabberd_app,start,2,[{file,"src/ejabberd_app.erl"},{line,67}]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},{line,269}]}]

I have found VERY LITTLE on the internet resolving this problem. Maybe there are about a half dozen posts out there with the gen_mod:start_module:78 error but no real solutions.

I have wasted 2 days trying to figure this out. Even trying on another server using ejabberd-2.1.10 but no dice. I am hitting my head against the wall and hard. Any help, direction, advice, etc is *greatly* appreciated.

Below is the barest custom module I've tested but still get the same error.

-module(mod_test).

-behaviour(gen_mod).

-export([start/2, stop/1]).

-include("ejabberd.hrl").
-include("logger.hrl").
-include("jlib.hrl").

start(_Host, _Opt) -> ok.

stop(_Host) -> ok.

Thanks in advance!!

Robert

Hi, I'm not sure if this

Hi,

I'm not sure if this would still be helpful, but I encountered the same problem you did. I followed the same tutorial you followed (http://metajack.im/2008/08/28/writing-ejabberd-modules-presence-storms/). I have outlined the steps I took to solve it below:

1. I couldn't get the simple module below to run with the ejabberd-13.12 without the ejabberd_logger error, so I decided to compile ejabberd from source (https://github.com/processone/ejabberd).
2. I added -define(LAGER, 1). to ejabberd/include/logger.hrl
3. Then, I compiled the code below using the command erlc -I ejabberd/include/ -pa ejabberd/deps/lager/ebin mod_test.erl
4. I copied the generated mod_test.beam file to /lib/ejabberd/ebin/.
5. I started ejabberd with the command sudo ejabberdctl start and it worked without the error.

I hope this helps. (FYI - I'm running Ubuntu 13.04).

Cheers.

-module(mod_test).

-behaviour(gen_mod).

-include("logger.hrl").

-export([start/2, stop/1]).

start(_Host, _Opts) ->
?INFO_MSG("mod_test starting", []),
    ok.

stop(_Host) ->
?INFO_MSG("mod_test stopping", []),
        ok.

I had the same issue. To fix

I had the same issue. To fix it, add the following to your module source code after the "export" function:

-ifndef(LAGER).
-define(LAGER, 1).
-endif.

Syndicate content