Search code examples
mojolicious

Mojolicious can't find my controller


I'm trying to get the project hosted on github running.

From the root directory I'm running

/LS30$ morbo bin/webserver

which starts the server. Navigating to http://ip:port/settings I get the following error

[Fri Jan 15 15:27:20 2016] [debug] Controller "LS30::Web::Settings" does not exist.

Now the controller is located here: LS30::Web::Controller::Settings so it is looking in the wrong place.

Since it is looking in the wrong place I figured why not copy the Settings controller (and the base controller) where it was looking - but this just gives me this error instead:

[Fri Jan 15 15:31:45 2016] [debug] Class "LS30::Web::Settings" is not a controller.

The routes look correct to a beginner, so I don't think it's that. In fact I suspect it's probably something wrong in my environment since I know this worked for the original author.

I'm very new to this so I'm not really sure what to do next:/


Solution

  • Mojolicious version 5.25 adds "Controller" automatically to a class name in an app when it's searching for a class to use to execute a route.

    In this case, the app is LS30::Web and it's looking for a class called Settings. Mojolicious 5.25 and later test the classes LS30::Web::Controller::Settings and LS30::Web::Settings but earlier versions test only the latter, which doesn't exist.

    The solution therefore, is to upgrade your Mojolicious to 5.25 or later. If you are using Ubuntu, upgrade to vivid or later. Otherwise, use CPAN or a tool such as cpanm to download and install the most recent Mojolicious from source.