I am trying to start a webapplication (where I use hibernate in), which worked already. Unfortunately, it somehow doesn't start anymore - or to be more specific: It does start, but it's always just showing "Reload is in progress..." in the console and doesn't open in the browser.
The "TerminServlet" is the welcome-file.
public class TerminServlet extends HttpServlet {
@Override
public void init(ServletConfig config)
throws ServletException {
super.init(config); //To change body of generated methods, choose Tools | Templates.
EntityManagerFactory emf = Persistence.createEntityManagerFactory("WebPU");
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
List<KalenderTag> tage = (List<KalenderTag>) em.createNamedQuery("loadKalenderTage").getResultList();
if(tage.size() == 0){
System.out.println("zero");
}
}
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet TerminServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet TerminServlet at " + request.getContextPath() + "</h1>");
out.println("</body>");
out.println("</html>");
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
And here you can see the output in the console. 
Aucun commentaire:
Enregistrer un commentaire