I have a web application (Maven project, JSP/SERVLET, TomCat 8.5.20). The application run perfectly in localhost (same TomCat version), but when i deploy to a live server, the following code doesn't work, the 'x01Json' (JSONObject) variable value be 'null' after i cal the transfromGameToJson() method.
Game init servlet, where i set JSON in request
X01Game x01Game = gameController.initX01Game(type, legsNumber, setsNumber, users, doubleIn, doubleOut, x01,
randomOrder, startingPoint);
JSONObject x01Json = gameController.transfromGameToJson(x01Game);
session.setAttribute("x01Game", x01Game);
request.setAttribute("x01Json", x01Json);
request.getRequestDispatcher("/darts/x01game.jsp").forward(request, response);
the method
public JSONObject transfromGameToJson(X01Game x01Game) {
ObjectMapper mapper = new ObjectMapper();
try {
mapper.writeValue(new File("x01Game.json"), x01Game);
JSONObject object = new JSONObject(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(x01Game));
return object;
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
If i delete this line from my method, it's working: