From 79721b7d5471da4803f9cf59a24f35524aea923e Mon Sep 17 00:00:00 2001 From: Pelayori <31128562+Pelayori@users.noreply.github.com> Date: Sun, 28 Apr 2024 22:44:54 +0200 Subject: [PATCH] Fix deployed exception --- src/main/java/com/uniovi/controllers/PlayersController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/uniovi/controllers/PlayersController.java b/src/main/java/com/uniovi/controllers/PlayersController.java index 80b80d6..68ba134 100644 --- a/src/main/java/com/uniovi/controllers/PlayersController.java +++ b/src/main/java/com/uniovi/controllers/PlayersController.java @@ -19,6 +19,7 @@ import jakarta.servlet.http.HttpSession; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Controller; @@ -246,9 +247,9 @@ public String changeRoles(HttpServletResponse response, @RequestParam String use @GetMapping("/player/admin/questionManagement") public String showQuestionManagementFragment(Model model) throws IOException { - File jsonFile = new File(QuestionGeneratorService.JSON_FILE_PATH); + Resource jsonFile = new ClassPathResource(QuestionGeneratorService.JSON_FILE_PATH); ObjectMapper objectMapper = new ObjectMapper(); - JsonNode json = objectMapper.readTree(jsonFile); + JsonNode json = objectMapper.readTree(jsonFile.getInputStream()); model.addAttribute("jsonContent", json.toString()); return "player/admin/questionManagement";