Closed ertankucukoglu closed 1 year ago
What happens when you step through the code once the exception happens? What does the call stack show ?
This is a service application. I am not quite sure how I can test it as a regular windows application to be able to run in debug mode.
Put a sleep(5000) line in the service start and then attach the IDE debugger.
Here is information I could collect using postman with POST request MVCFramework.pas:2540
This using the framework sources from yesterday.
One thing I am not sure is if it is OK to use a POST method and use Query parameters as input in the sources for the method as codes has following references
Context.Request.QueryStringParam('user')
Context.Request.QueryStringParam('pass')
Edit: After checking again code execution is not there for these references to become a problem. Exception is earlier so problem must be something else.
OK, it looks like you are mixing something up because the Exception message you initially posted had a message of "Cannot create controller" but the code you are stopped on would give "Not Found". You can see where that exception be raised around line 2462. So you seem to have a number of issues.
Back to the code above though, here's some things to take away and share with your friend.
The framework maps the request to the controller action using 4 key things:
So show us your postman inputs: URL, headers, body etc.
And figure out what makes the code reach the exception on line 2462 which was your original question. My guess is that something in the constructor of your controller class is incorrect and the constructor blows up, which is caught by the MVCFramework. Show us the code in the constructor.
Initial question, log records are taken from production server. In order to be able to debug, I had to use development computer. Likely, there are some issues with it.
Just posting requested information now and I will try to walk back in the stack trace later Body, is empty
TApi constructor is as following
constructor TApi.Create;
begin
inherited;
FDConn := TFDConnection.Create(nil);
FDConn.ConnectionDefName := 'DevriyeConnX';
//s:=FDConn.ConnectionString;
FDConn.Connected := True;
ActiveRecordConnectionsRegistry.AddDefaultConnection(FDConn);
end;
Just to be complete, production uses command line version. Which seemingly works fine for a few requests even for a few hours sometimes. Later, initial log errors appears.
We are trying to switch to service application as we suspect windows logouts or does some other weird things for the error to occur. Not 100% sure though.
Edit: Figured my mistake that I should not start with /rest
but directly with /api
Will share new stack trace of actual error hopefully.
Ok, my guess is the constructor is having issues with the DB connection. Which explains the text of the original (outer) exception "Unknown connection default"
So this is not an MVC problem as far as I can see. I'm not familiar with the DB library. Maybe ask on the facebook group ?
I could run as service application now. Seems to be fine for the time being. If problem continues, that will be known in about 8 hours. If it continues, I will add logging at the constructor in order to be sure about it. I cannot run debug run on the production server at the moment for getting a call stack. Thank you for your help.
You can add a global exception handler to the MVC Engine instance and then write out the call stack to the log from some code in there. We use Eurekalog to get the call stack as formatted text, and find it invaluable.
I'm not familiar with the DB library
Is it possible to use UniDAC with MVC?
@ertankucukoglu you can use any db library with dmvcframework, but TMVCActiveRecord uses FireDAC. If you are not interested in TMVCACTIVERECORD you can use anything.
Any news on this?
Actually, we could not figure out the reason of the exception. It does come occasionally make it console application or service application is no difference.
Due to the pressure from customers, we had to find an alternative solution for the time being.
if you can provide a small, self-contained sample I can give a look to it.
Il giorno gio 24 nov 2022 alle ore 08:26 ertankucukoglu < @.***> ha scritto:
Actually, we could not figure out the reason of the exception. It does come occasionally make it console application or service application is no difference.
Due to the pressure from customers, we had to find an alternative solution for the time being.
— Reply to this email directly, view it on GitHub https://github.com/danieleteti/delphimvcframework/issues/593#issuecomment-1326054097, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAK4ZJBMJOESTWWWQ76ZK7LWJ4KCFANCNFSM6AAAAAASE35Q2M . You are receiving this because you commented.Message ID: @.***>
-- Daniele Teti CEO & CTO bit Time Professionals website [it]: www.bittimeprofessionals.it website [en]: www.bittimeprofessionals.com blog: www.danieleteti.it my last book on leanpub https://leanpub.com/delphimvcframework my previous books on amazon https://www.amazon.it/s?i=stripbooks&rh=p_27%3ADaniele+Teti mobile: +39 3496626822 office: +39 06 20761499
I will see if I can collect necessary information. I prefer not to pass this information in public though. @danieleteti I got codes, old log file available. How can I share them in private? Thanks.
Yes, you can "professionals (at) bittime (dot) it"
Hello,
I do not know the framework. Just trying to help a friend as he does not know English. He do not know the framework, too. Though I read about the framework as much as I can before posting. Please bare with me.
Problem is that we get cannot create controller error as below
I see login defined in the controller class
I also see controller class is used in the engine as following
There are no middleware loaded.
Without some knowledge about the framework, I could not figure what's wrong. I just believe this is a very basic error in code/definitions as no such question asked in the issues before.
Any help is appreciated.
Thanks & Regards, Ertan