The problem is that when I run the Spring application on my laptop, everything works fine, and when I transfer it to the server in Tomcat, the interesting begins. The first request with FormData goes through and is processed normally, everything is entered into the database, but subsequent requests fail with a 500 error without a message.
Here is an example of an error response:
{
"timestamp": "2021-12-02T22: 53: 08.872 + 00: 00",
"status": 500,
"error": "Internal Server Error",
"message": "",
"path": "/hustle /api /catalog /add"
}
And here is the controller method that handles the request:
@RequestMapping (
value= ["add"],
method= [RequestMethod.POST],
consumes= ["multipart /form-data"]
)
fun add (
@RequestParam ("image") file: MultipartFile,
@RequestParam ("name") name: String,
@RequestParam ("longName") longName: String,
@RequestParam ("description") description: String,
@RequestParam ("price") price: Int
): DataWrapper <
Any >
{
return try {
//write to the database
} catch (ex: Exception) {
//error output (not 500)
}
}
As for the project settings, they are completely default, with the exception of a couple of points:
Added 3 lines to the settings so that the file can be loaded
- spring.servlet.multipart.max-file-size= 10MB
- spring.servlet.multipart.max-request-size10MB
- spring.servlet.multipart.enabled= tru *
Added spring-boot-starter-web dependencies and removed request size limitation in Tomcat settings.
Everything would be better if it didn't work at all, and the fact that it works the first time is confusing.
Thanks in advance for your help.
@Mira, supplemented the answer with an error message
LeonSolya2021-12-05 00:54:09Okay, a fair minus, this is a jamb of tomato, and if I immediately thought of pulling out the logs from the server, I would fix everything myself
LeonSolya2021-12-05 00:54:09normal question you have :)
Mira2021-12-05 00:54:09- java : The proxy comes to the postProcessBeforeInitialization method, not the original class
- Java Why does Spring -Tomcat close all connections it has created?
- Java.lang.UnsupportedOperationException: null
- java : .Sig Crypto Pro JCP Signature File Validation Not Working
- java : ExecutorService. All running threads begin to perform the task of the last
- java : Launching an Activity located in another module
- java : Why isn't the transaction rolled back?
- Grouping objects by fields. Java
- java : Pass parameter to controller from form
500 is the http code. The whole error of the spring is written on the server side, look in the logs there with what it crashes and copy the text here.
Mira2021-12-05 00:54:09