Spring MVC returning 500 error? How can I debug it? - spring-mvc

I have a project using spring MVC.
The request is recieved correctly.
The dispatcher servlet correctly maps the request to the controller.
The controller correctly processes the request and generates the proper response
The model-map is populated and the correct view is returned
At this point spring magic kicks in and I lose track of the specifics of what's going on.
On the client-side, the response (via firebug) is a 500 error and nothing else. Without firebug my client just hangs.
I have no idea how I can debug the dispatcher servlet, and figure out what the problem is. I can't step through the spring binaries with a debugger, and it's not throwing any sort of exception so I can't look at a stack trace. All I have to look at are configuration files which, i'm almost 100% certain are fine.
What steps can I take to debug this problem? What tools or approaches can I use?
Details:
I'm using Eclipse IDE, Java EE 7 and an ant script to build the project. I'm deploying to tomcat 7.

Related

Client app able to call API Locally but unable to do it in IIS

I have an application that his a .Net Core API.
Everything works locally, and by that means,
Client App --> hits an .Net Core API successfully.
Howevever we have pushed the app to IIS Server, and we are not able to successfuly hit the API.
I know this is extremely vague, but what is something that I should be looking at to diagnose address this. I pulled the code from the published branch, and it works like a charm on local, but does not work on Server.
I do not get any Server Side exceptions.
Is there network connectivity? Log into the server and open a browser and put in the URL to the API. Any HTTP error is good. It means you can reach the API. If it times out, that's bad and that's your problem.
How do you know there are no exceptions? Are you logging all exceptions? Are you sure no exceptions are hidden in try blocks that end up ignoring the exception?
Assuming it's a Windows server, check the Event Viewer for warnings or errors.

ASP.NET Web API - Some controllers return 404 status code

A couple of days ago, all endpoints on certain API controllers of our application started returning 404 - as if the endpoint doesn't exist at all. Some other API controllers were working correctly, meaning that all endpoints within these controllers work as expected.
The API controllers are consumed by the Angular.js part of the monolith application (jQuery, Ajax).
This application, including the controllers that stopped working, have been running for years without this issue ever occurring.
It is an ASP.NET 4.7.2 MVC application, that in addition to MVC controllers has API controllers as well. It also has Umbraco 7 installed, so the Startup class inherits from UmbracoDefaultOwinStartup. The app is deployed to Azure App Service, using Azure DevOps Pipelines. Note: The issue is only on some API controllers, all MVC controllers work correctly.
The code, when run on localhost, doesn't show the errors, everything works normally, it's just that the deployed environment has the issue.
Here is what we changed during the period when the issue started occurring, which might have caused the issue in the first place:
Updated the Azure DevOps Pipeline Agent pool from Hosted VS2017 Agent pool to Azure pipelines windows-2019 (as we received a warning that vs 2017 and windows-2016 images will be deprecated). More info on this url: https://github.com/actions/virtual-environments/issues/4312
Made changes on the Gruntfile.js, BundleConfig.cs, and Master.cshtml files
What we tried so far:
running the app in localhost - unable to recreate the issue, localhost works fine
reverting the changes made on the files - the issue still persists
set the pipelines Agent pool to vs2017-win2016 - the issue still persists. I was not able to set it completely back to Hosted VS2017 Agent pool as it is deprecated. This means that, if the issue was caused by changing the Agent pool, I was not able to revert it.
testing the endpoints that don't work via Postman, adding logs within the controller actions to see whether the endpoint will be triggered - but it always simply returns 404 without ever entering the controller action
UPDATE: we've reset the remote branch to a state where we're certain that all APIs were working correctly, but the 404 status codes persist. This indicates that this issue isn't caused by changes in code, but rather something environment specific.
UPDATE 2: when reviewing the LogFiles folder through Kudu DebugConsole, I've found that all these 404 requests have the following logged event, so this proves that the ednpoint isn't recognized at all:
MODULE_SET_RESPONSE_ERROR_STATUS
ModuleName IIS Web Core
Notification MAP_REQUEST_HANDLER
HttpStatus 404
HttpReason Not Found
HttpSubStatus 0
ErrorCode The system cannot find the file specified. (0x80070002)

No mapping found for HTTP request with URI [/] in DispatcherServlet with name 'dispatcher'

I know that this question was asked multiple times on stackoverflow and I had read almost all of them to solve my error. But my requirement is different from others and all my efforts to accomplish this are in vain.
Developing a web app using Spring MVC , Google Data store and running it on App Engine.
This is my Project Structure:
My Web.xml file:
My Controller to handle requests:
My Context file for Dispatcher Servlet:
The Error log generated:
My project is running on Tomcat server without any errors on another machine. I am encountering this error only on Google App engine.
Help me to sort this error out.
This is the link for my project https://drive.google.com/open?id=1H7z34ZEPr3HniWJsrEaHYIxKUWOf_67P
The reason why this program is not executing is , In the dispatcher-servlet.xml , In xsi:schemalocation tag , For spring mvc url , I used 4.0 version. That's why this code didn't execute. After removing the version, It executed perfectly

How to prevent method with #postcontruct annotation from being executed during server startup

I am developing a web-application using JSF2.1 and Spring MVC. I have written #PostConstruct for methods which i need to execute on page load. The beans are all ViewScoped. But the problem is that the method is executed on server startup and initialized then and the same instance is used during page load. Is there any way to get the method to run only during page load ?
This will happen when you're running the server from inside an IDE like Eclipse. The IDE's server plugin such as Eclipse Tomcat plugin will after the startup process do a self-test by sending a GET request to /. Apparently you've on / a page associated with those view scoped beans.
Ignore it. This wouldn't happen during production.

Why am I getting 404 on my web service locally

I am working with a web service written using .NET wcf. When running locally, I can go to the wsdl by going to the url of the svc file but I get a 404 error when I try to go to one of the service methods ex Api.svc/GetPrice
Any thoughts about what could be causing this? The service is running on production. (I just need to fix a bug with the data.)
Difficult to say based on the information you've provided, but have you tried to ensure that IIS and WCF are correctly installed and registered? I've forgotten to do this before and I believe it results in a 404.

Resources