benoitc / couchbeam

Apache CouchDB client in Erlang
Other
242 stars 114 forks source link

Cannot start couchbeam without ibrowse:start() #50

Closed DimitryDushkin closed 13 years ago

DimitryDushkin commented 13 years ago

I was using manual on http://benoitc.github.com/couchbeam/, but if I do so, I got an error:

exception error: bad argument
     in function  ets:lookup/2
        called as ets:lookup(ibrowse_lb,{"localhost",5984})
     in call from ibrowse:send_req/6
     in call from couchbeam:request/6
     in call from couchbeam:server_info/1

My code is:

save_to_db() ->
    st_utils:load_libraries(),
    application:start(ibrowse),
    application:start(couchbeam),
    CouchDb = couchbeam:server_connection("localhost", 5984, "", []),
    couchbeam:server_info(CouchDb). 

load_libraries() ->
    ProjectRoot = filename:join([filename:absname("./"), "site_stater"]),
    {ok, DepsList} = file:list_dir(ProjectRoot ++ "/deps/"),
    lists:foreach(fun (Folder) ->
                       EbinFolder = ProjectRoot ++ "/deps/" ++ Folder ++ "/ebin",
                       case filelib:is_dir(EbinFolder) of
                           true ->
                               code:add_patha(EbinFolder);
                           false -> ok
                       end
                  end,
                DepsList),
    ok.

But if I replace application:start(ibrowse) to ibrowse:start(), everything works fine

{ok,{[{<<"couchdb">>,<<"Welcome">>},
      {<<"version">>,<<"1.1.1">>}]}}

Did I something wrong or is manual wrong?

akaspin commented 13 years ago

Try application:start(sasl) before application:start(ibrowse). ibrowse needs sasl. I ran into this when I started using ibrowse. Don't use ibrowse:start(). When you do this, you run ibrowse gen_server in debug mode.

DimitryDushkin commented 13 years ago

You absolutly totally right! Thank you. I think it should be mentioned in manual (application:start(sasl)).

DimitryDushkin commented 13 years ago

I think it should be mentioned in manual (application:start(sasl)).

benoitc commented 13 years ago

fixed in 86132aae2220e32c12b4c3fa791d9fe36179ef9f thanks!