You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, I just made a class called Project, have a repository, controller and a service. I will attach these below but first I'll try to explain my issue. So I basically made a project controller where I wanna create, and findbyid, findbyownerid and list all projects. (First i just wanted create and findbyownerid, i added the others to test). My issue is that the create works fine with the .save(). It saves it in mongodb all fine. But on any get request i get a 500 Internal Error.
This is the log for getallprojects for example: 2024-12-23T22:14:09.579+01:00 DEBUG 9475 --- [cms] [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : GET "/project/", parameters={} 2024-12-23T22:14:09.580+01:00 DEBUG 9475 --- [cms] [nio-8080-exec-4] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to com.globytes.cms.contollers.ProjectController#getAll() 2024-12-23T22:14:09.596+01:00 DEBUG 9475 --- [cms] [nio-8080-exec-4] .m.m.a.ExceptionHandlerExceptionResolver : Using @ExceptionHandler com.globytes.cms.exception.GlobalExceptionHandler#handleException(Exception) 2024-12-23T22:14:09.596+01:00 DEBUG 9475 --- [cms] [nio-8080-exec-4] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Using 'application/json', given [*/*] and supported [application/json, application/*+json] 2024-12-23T22:14:09.597+01:00 DEBUG 9475 --- [cms] [nio-8080-exec-4] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Writing [com.globytes.cms.exception.ExceptionResponse@407f96c6] 2024-12-23T22:14:09.598+01:00 WARN 9475 --- [cms] [nio-8080-exec-4] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.springframework.data.mapping.MappingException: Parameter org.springframework.data.mapping.Parameter@31acf732 does not have a name] 2024-12-23T22:14:09.598+01:00 DEBUG 9475 --- [cms] [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Completed 500 INTERNAL_SERVER_ERROR
Response in Postman: { "message": "An error occurred", "error": "Internal Server Error", "status": 500 }
This looks like you need to make sure to configure the compiler to use the -parameters flag.
See also Spring Framework 6.0 Release Notes.
If that does not work and you'd like us to spend some time investigating, please take the time to provide a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem.
Hey, I just made a class called Project, have a repository, controller and a service. I will attach these below but first I'll try to explain my issue. So I basically made a project controller where I wanna create, and findbyid, findbyownerid and list all projects. (First i just wanted create and findbyownerid, i added the others to test). My issue is that the create works fine with the .save(). It saves it in mongodb all fine. But on any get request i get a 500 Internal Error.
This is the log for getallprojects for example:
2024-12-23T22:14:09.579+01:00 DEBUG 9475 --- [cms] [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : GET "/project/", parameters={} 2024-12-23T22:14:09.580+01:00 DEBUG 9475 --- [cms] [nio-8080-exec-4] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to com.globytes.cms.contollers.ProjectController#getAll() 2024-12-23T22:14:09.596+01:00 DEBUG 9475 --- [cms] [nio-8080-exec-4] .m.m.a.ExceptionHandlerExceptionResolver : Using @ExceptionHandler com.globytes.cms.exception.GlobalExceptionHandler#handleException(Exception) 2024-12-23T22:14:09.596+01:00 DEBUG 9475 --- [cms] [nio-8080-exec-4] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Using 'application/json', given [*/*] and supported [application/json, application/*+json] 2024-12-23T22:14:09.597+01:00 DEBUG 9475 --- [cms] [nio-8080-exec-4] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Writing [com.globytes.cms.exception.ExceptionResponse@407f96c6] 2024-12-23T22:14:09.598+01:00 WARN 9475 --- [cms] [nio-8080-exec-4] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.springframework.data.mapping.MappingException: Parameter org.springframework.data.mapping.Parameter@31acf732 does not have a name] 2024-12-23T22:14:09.598+01:00 DEBUG 9475 --- [cms] [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Completed 500 INTERNAL_SERVER_ERROR
Response in Postman:
{ "message": "An error occurred", "error": "Internal Server Error", "status": 500 }
My Project class:
`import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@DaTa
@document(collection="projects")
public class Project {
}
`
My project repository:
`import java.util.List;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import com.globytes.cms.models.Project;
@repository
public interface ProjectRepository extends MongoRepository<Project, String> {
}
`
My project service:
`import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import com.globytes.cms.models.Project;
import com.globytes.cms.models.dtos.ProjectRequest;
import com.globytes.cms.repositories.ProjectRepository;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
@service
public class ProjectService {
}`
And I'm not attaching the controller since its just a return of the service methods.
Any help is appreciated but im literally going insane, i have no idea what is wrong, I've tried everything I could think of.
Thanks
The text was updated successfully, but these errors were encountered: