views:

121

answers:

3

I have written a simple erlang app using gen_server.

When starting it with application:start(myapp), I get the following tuple...

{error,{bad_application,{appliction,myapp ... (rest of my application config).

There are no other error or warning messages. I have also tried to google examples of how to configure gen_server and also the error itself. I am surprised at how little information there is out there.

I could start trying to debug OTP?? Any pointers would be appreciated.

+2  A: 

There is quite a lot of information on how to implement an erlang application in the "Application" section of OTP Design Principles. It sounds like you are trying to use a gen_server as the callback for the application you are starting. That just wont work.

The most common setup for an application is to have an application callback module that starts up a supervisor that has a gen_server somewhere as a worker. Applications do not need to start any processes at all. Applications can exists purely to load some library modules into the vm, such as the stdlib application. That makes it possible for other applications to have dependencies on libraries.

Christian
Thanks for the link Christian. Actually, I am trying to start a stock standard erlang application as per the following article. My ultimate aim is to access python code via a 'port'. http://www.trapexit.org/Writing_an_Erlang_Port_using_OTP_PrinciplesI get all the way to the point of starting the application with 'application:start(appname).' I'm wondering how to troubleshoot from this point?
andyc
+1  A: 

You might also want to have a look to the following tutorial on how to debug Erlang functions:

http://aloiroberto.wordpress.com/2009/02/23/tracing-erlang-functions/

Roberto Aloi
Thanks Roberto that seems like a very useful idea.
andyc
+1  A: 

I assume there is an error in your config file. One thing you could try to do is

file:consult("<your-app-config-file>").

If it returns an error, you'll know thats the problem..

arun_suresh
Good suggestion arun_suresh, and ultimately it was a typo in my config file, 'appliction'. Thanks!
andyc