Erlang Mailing Lists

Author Message

<  Erlang Web mailing list  ~  [Erlangweb-users] Problems in step1 of tutorial

jeffm
Posted: Thu Mar 18, 2010 7:59 am Reply with quote
User Joined: 29 Sep 2008 Posts: 43
Following the tutorial at

http://wiki.erlang-web.org/Tutorial/Step1_Setup

with release 1.4 of erlang web. I get up to testing /item/show/1 but I
get a 404 in the web browser. My first suspicions was that I'd mistyped
the dispatch rules in dispatch.conf, so I cut and pasted them from the
tutorial then restarted erlang web. I also added an io:format/2 to the
browser:show_item/1 to see if it at lest made it this far...doesn't
appear that it does. The log says,

e_mod_gen module, error: 404: "/item/show/1"

What should I check next?

thanks,
Jeff.


------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Erlangweb-users mailing list
Erlangweb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlangweb-users
http://www.erlang-web.org/
Post received from mailinglist
View user's profile Send private message
enmanks
Posted: Thu Mar 18, 2010 8:37 am Reply with quote
Joined: 18 Sep 2009 Posts: 2
hmm...
This rule in dispatch.conf

{dynamic, "^/item/show/(?<id>[0-9]+)$", {browser, show_item}}.

does not work for me for "/item/show/1".

You can try this one:
{dynamic, "^/item/show/([0-9]+)$", {browser, show_item}}.


[/code]

On Thu, Mar 18, 2010 at 9:43 AM, Jeffm <jeffm@ghostgun.com (jeffm@ghostgun.com)> wrote:
Quote:
Following the tutorial at

http://wiki.erlang-web.org/Tutorial/Step1_Setup

with release 1.4 of erlang web. I get up to testing /item/show/1 but I
get a 404 in the web browser. My first suspicions was that I'd mistyped
the dispatch rules in dispatch.conf, so I cut and pasted them from the
tutorial then restarted erlang web. I also added an io:format/2 to the
browser:show_item/1 to see if it at lest made it this far...doesn't
appear that it does.
View user's profile Send private message
Guest
Posted: Thu Mar 18, 2010 1:37 pm Reply with quote
Guest
On 03/18/2010 07:43 AM, Jeffm wrote:
> Following the tutorial at
>
> http://wiki.erlang-web.org/Tutorial/Step1_Setup
>
> with release 1.4 of erlang web. I get up to testing /item/show/1 but I
> get a 404 in the web browser. My first suspicions was that I'd mistyped
> the dispatch rules in dispatch.conf, so I cut and pasted them from the
> tutorial then restarted erlang web. I also added an io:format/2 to the
> browser:show_item/1 to see if it at lest made it this far...doesn't
> appear that it does. The log says,
>
> e_mod_gen module, error: 404: "/item/show/1"
>
> What should I check next?
You might want to debug what's happening behind the scenes.
In Erlang, it's extremely easy to trace functions, so that you can check
which function has been called, when, and what it's returning.

In your case, you might be interested in the function:
e_dispatcher:dispatch/1

Tracing functions will help you (a lot!) in understanding how the whole
Erlang Web framework works.

For more information on how to trace Erlang functions, have a look to
this quick reference:
http://aloiroberto.wordpress.com/2009/02/23/tracing-erlang-functions/

Regards,

Roberto Aloi

--
University of Kent - Erlang Solutions Ltd.
Twitter: @prof3ta
Blog: http://aloiroberto.wordpress.com
---------------------------------------------------

---------------------------------------------------

WE'VE CHANGED NAMES!

Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.

www.erlang-solutions.com


------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Erlangweb-users mailing list
Erlangweb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlangweb-users
http://www.erlang-web.org/
Post received from mailinglist
Guest
Posted: Thu Mar 18, 2010 1:37 pm Reply with quote
Guest
On 03/18/2010 08:37 AM, Elena Bobrova wrote:
> hmm...
> This rule in dispatch.conf
>
> {dynamic, "^/item/show/(?<id>[0-9]+)$", {browser, show_item}}.
>
> does not work for me for "/item/show/1".
>
> You can try this one:
> {dynamic, "^/item/show/([0-9]+)$", {browser, show_item}}.
You might want to keep that "id", since it could be extremely helpful.
In your controller, you'll be able to refer easily to that parameter by
name, instead of scanning the list of all available arguments.

Cheers,

Roberto Aloi

--
University of Kent - Erlang Solutions Ltd.
Twitter: @prof3ta
Blog: http://aloiroberto.wordpress.com
---------------------------------------------------

---------------------------------------------------

WE'VE CHANGED NAMES!

Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.

www.erlang-solutions.com


------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Erlangweb-users mailing list
Erlangweb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlangweb-users
http://www.erlang-web.org/
Post received from mailinglist
jeffm
Posted: Fri Mar 19, 2010 5:33 am Reply with quote
User Joined: 29 Sep 2008 Posts: 43
Alright folks I'm an idiot. I must have started a copy in the
background with the bin/start script and it was the one answering
requests. It wasn't until I tried the trace that you suggested below
that I notice that I wasn't getting requests to the instance I was
looking at. Thanks.

I did notice one thing while debugging. If you don't have the brackets
in the regexp in the dispatch.conf file balanced and attempt to start
erlang-web, say via bin/start_interactive, you get something like

=PROGRESS REPORT==== 19-Mar-2010::11:58:36 ===
application: inets
started_at: nonode@nohost
{"init terminating in
do_boot",{badarg,[{e_conf,dbms,0},{e_db,start,0},{init,start_it,1},{init,start_em,1}]}}

Crash dump was written to: erl_crash.dump
init terminating in do_boot ()

The first time this occurred there was a list of integers in the
erl_crash.dump which happened to decode to an erlang error. This can
also be seen in the log messages on screen once you know what your
looking for but can still be hard to see.

For example,

exception exit: {bad_return,
{{eptic,start,[normal,[]]},
{'EXIT',
{{badmatch,{error,{"unmatched
parentheses",24}}},
[{e_dispatcher,divide,3},
{e_dispatcher,install,0},
{lists,foreach,2},
{eptic,start_link,0},
{application_master,start_it_old,4}]}}}}

If possible I'd like to put in a feature request that this error be
caught and a meaningful error displayed.

Jeff.


On 19/03/10 12:18 AM, Roberto Aloi wrote:
> You might want to debug what's happening behind the scenes.
> In Erlang, it's extremely easy to trace functions, so that you can check
> which function has been called, when, and what it's returning.
>
> In your case, you might be interested in the function:
> e_dispatcher:dispatch/1
>
> Tracing functions will help you (a lot!) in understanding how the whole
> Erlang Web framework works.
>
> For more information on how to trace Erlang functions, have a look to
> this quick reference:
> http://aloiroberto.wordpress.com/2009/02/23/tracing-erlang-functions/
>
> Regards,
>
> Roberto Aloi
>
>


------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Erlangweb-users mailing list
Erlangweb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlangweb-users
http://www.erlang-web.org/
Post received from mailinglist
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum