2
votes

I try to write application to my Erlang program.

I have test_app.erl:

-module(test_app).

-behaviour(application).

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

start(_Type, _StartArgs) ->
    test_sup:start_link().

stop(_State) ->
  ok.

And .app file:

{application, test,
  [{description, "test system."},
  {vsn, "1.0"},
  {modules, [test_app, test_sup, fsm]},
  {registered, [test_sup, fsm]},
  {applications, [kernel, stdlib]},
  {mod, {test_app, []}}
]}.

When i try to start application:

application:start(test).

I get error:

=INFO REPORT==== 18-Feb-2011::19:38:53 ===
    application: test
    exited: {bad_return,
                {{test_app,start,[normal,[]]},
                 {'EXIT',
                     {undef,
                         [{test_sup,start_link,[[]]},
                          {test_app,start,2},
                          {application_master,start_it_old,4}]}}}}
    type: temporary
{error,{bad_return,{{test_app,start,[normal,[]]},
                    {'EXIT',{undef,[{test_sup,start_link,[[]]},
                                    {test_app,start,2},
                                    {application_master,start_it_old,4}]}}}}}

What's wrong? How can i fix it?

If i make in eshell:

test_app:start(normal, []).

Than all works.

Thank you.

1
It's telling you that the function test_sup:start_link([]) doesn't exist ({test_sup,start_link,[[]]}), yet you're calling it with test_sup:start_link() in the code you gave us. Moreover, your .app file shows that the module epmail_app is the one that should be called while your application clearly starts with test_app. Is there stuff you haven't posted correctly or am I just imagining things? If it'S the case, Yasir's reply is right with regards to the return values. - I GIVE TERRIBLE ADVICE
Also, it could be handy to see the code of the supervisor test_sup. - Ricardo
I think supervisor code is well, because if i try to run supervisor by hand all ok. - 0xAX
Did you recompile all of your modules? - YasirA

1 Answers

3
votes

I suppose this might be caused by not loading the [proper] .beam. Ensure that all modules are in the same directory, or try to use -pa key to erl(1), e. g.:

$ erl -pa ../ebin
1> application:start(test).
...