drogonframework / drogon

Drogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows
MIT License
11.57k stars 1.12k forks source link

Error message indicating `Controller class not found` in drogon v1.9.2 which did not appear in v1.9.1 #1919

Closed eniv closed 9 months ago

eniv commented 9 months ago

I have something which looks like this:

drogon::app().loadConfigFile(std::string("./") + APP_STRING_NAME + "_server/config.json");
auto cis_http_controller =  std::make_shared<APP_NAME::cis_controller>();
drogon::app().registerController<APP_NAME::cis_controller>(cis_http_controller);
auto drogon_main = std::thread([]{drogon::app().run();});

which worked OK with v1.9.1 but is flagging the issue in the title from drogon/lib/src/HttpControllersRouter.cc line 237. Can you think of something that had changed which would cause that? Thanks in advance.

an-tao commented 9 months ago

@eniv thanks for your feedback. but I can't reproduce the problem in my environment. please paste the entire error log line, including the controller name. BTW: I tested your code in my linux server with drogon 1.9.2, it works fine. And if your controller constructor has no parameters, there is no need to create it manually.

eniv commented 9 months ago

Thanks for the quick response. I'm also on Linux. This is the exact error message: 20240124 03:51:47.860891 UTC 338518 ERROR Controller class not found: controllerClassName - HttpControllersRouter.cc:237 I got into the habit of manually creating controllers to keep things consistent with controllers whose constructors do take parameters.

Could it be related to a config setting? I've attached my config.json which I've been using since version 1.8.4 (if I remember correctly)

an-tao commented 9 months ago

Please remove the simple_controllers_map option in the configuration file.

eniv commented 9 months ago

That was it. Thank you!