Проблема с Tomcat - “Приложение было развёрнуто в контекстном пути [/SchoolMaven], но не стартовало”

135
18 ноября 2020, 06:10

Из-за чего может быть такая ошибка

OK - Неразвернутое приложение в контексте пути [/SchoolMaven]
    Развертывание на месте на C:\Users\Fallen\Documents\NetBeansProjects\SchoolMaven\target\SchoolMaven
    Выполняется развертывание...
    deploy?config=file%3A%2FC%3A%2FUsers%2FFallen%2FAppData%2FLocal%2FTemp%2Fcontext3285273547592175075.xml&path=/SchoolMaven
    ОШИБКА - Приложение было развёрнуто в контекстном пути [/SchoolMaven], но не стартовало

Вот коды

Controller

package adil.java.schoolmaven.controller;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import adil.java.schoolmaven.entity.Student;
import adil.java.schoolmaven.service.StudentService;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class StudentController {
    private final static File UPLOAD_FOLDER = new File(System.getProperty("user.dir") + "/avatars/");
    static {
        if (!UPLOAD_FOLDER.exists()) {
            UPLOAD_FOLDER.mkdirs();
        }
    }
    // Constructor based Dependency Injection
    private StudentService studentService;
    public StudentController() {
    }
    @Autowired
    public StudentController(StudentService studentService) {
        this.studentService = studentService;
    }

    @RequestMapping(value = {"/", "/index"}, method = RequestMethod.GET)
    public ModelAndView hello(HttpServletResponse response) {
        ModelAndView mv = new ModelAndView();
        mv.setViewName("index");
        return mv;
    }
    // Get All Users
    @RequestMapping(value = "/allStudents", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView displayAllUser() {
        System.out.println("User Page Requested : All Students");
        ModelAndView mv = new ModelAndView();
        List<Student> studentList = studentService.getAllStudents();
        mv.addObject("studentList", studentList);
        mv.setViewName("allStudents");
        return mv;
    }
    @RequestMapping(value = "/addStudent", method = RequestMethod.GET)
    public ModelAndView displayNewUserForm() {
        ModelAndView mv = new ModelAndView("addStudent");
        mv.addObject("headerMessage", "Add Student Details");
        mv.addObject("student", new Student());
        return mv;
    }
    @PostMapping(value = "/addStudent")
    public String saveNewStudent(@RequestParam("name") String name,
            @RequestParam("surname") String surname,
            @RequestParam("avatar") MultipartFile file)
            throws IOException {
        if (file != null && !file.isEmpty()) {
            Student student = new Student();
            student.setSurname(surname);
            student.setSurname(name);
            student.setAvatar(file.getBytes());
            studentService.saveStudent(student);
        }
        return "redirect:/allStudents";
    }
    @RequestMapping(value = "/image", method = RequestMethod.GET)
    public void image(@RequestParam String url, HttpServletResponse response) throws IOException {
        InputStream in = new FileInputStream(url);
        response.setContentType(MediaType.IMAGE_JPEG_VALUE);
        IOUtils.copy(in, response.getOutputStream());
    }
    @RequestMapping(value = "/editStudent/{id}", method = RequestMethod.GET)
    public ModelAndView displayEditUserForm(@PathVariable Long id) {
        ModelAndView mv = new ModelAndView("/editStudent");
        Student student = studentService.getStudentById(id);
        mv.addObject("headerMessage", "Редактирование студента");
        mv.addObject("student", student);
        return mv;
    }
    @RequestMapping(value = "/editStudent/{id}", method = RequestMethod.POST)
    public ModelAndView saveEditedUser(@ModelAttribute Student student, BindingResult result) {
        ModelAndView mv = new ModelAndView("redirect:/allStudents");
        if (result.hasErrors()) {
            System.out.println(result.toString());
            return new ModelAndView("error");
        }
        boolean isSaved = studentService.saveStudent(student);
        if (!isSaved) {
            return new ModelAndView("error");
        }
        return mv;
    }
    @RequestMapping(value = "/deleteStudent/{id}", method = RequestMethod.GET)
    public ModelAndView deleteUserById(@PathVariable Long id) {
        boolean isDeleted = studentService.deleteStudentById(id);
        System.out.println("Удаление студента: " + isDeleted);
        ModelAndView mv = new ModelAndView("redirect:/allStudents");
        return mv;
    }
}

Add Student JSP

    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
    <title>Home</title>
    </head>
    <body>
        <div class="add">
            <br>
        <br>
        <br>
        <br>
        <center>
        <h1>${headerMessage}</h1>
            <form:form method="POST" action="/addStudent" enctype="multipart/form-data">
                 <table>
                    <tr>
                        <td><label path="Name">Имя</label></td>
                        <td><input type="text" name="name"/></td>
                    </tr>
                    <tr>
                        <td><label path="Surname">Фамилия</label></td>
                        <td><input type="text" name="surname"/></td>
                    </tr>
                    <tr>
                        <td><label path="Avatar">Фотография:</label></td>
                        <td>
                            <input type="file" name="avatar"/>
                        </td>
                    </tr>
                    <tr>
                        <td><input class="btn btn-primary" type="submit" value="Добавить"></td>
                    </tr>
                </table>
            </form:form>
    </center>
            </div>
    </body>
    </html>
All Student JSP
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" isELIgnored="false"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
  <link href="../css/style.css" rel="stylesheet" type="text/css">
  <style><%@include file="/WEB-INF/css/style.css"%></style>
<title>Все студенты</title>
</head>
<body>
    <br>
    <br>
    <br>
    <br>
    <div class="it">
    <h3>Список всех студентов</h3>
    ${message}
    <br>
    <br>
    <table class="table">
  <thead>
    <tr>
      <th scope="col">#</th>
      <th scope="col">Имя</th>
      <th scope="col">Фамилия</th>
      <th scope="col">Фото</th>
    </tr>
  </thead>
  <tbody>
      <c:forEach var="student" items="${studentList}">
                <tr>
                    <th scope="row">1</th>
                    <td>${student.name}</td>
                    <td>${student.surname}</td>
                     <td><img src="data:image/jpg;base64,${student.base64Image}" style="max-height: 200px; max-width: 200px;" /></td>
                     <td><a
                        href="${pageContext.request.contextPath}/editStudent/${student.id}"><button type="button" class="btn btn-primary">Редактировать</button>
                    <td><a
                        href="${pageContext.request.contextPath}/deleteStudent/${student.id}"><button type="button" class="btn btn-primary">Удалить</button>

                </tr>
            </c:forEach>
        </tbody>

    </table>
    <a href="${pageContext.request.contextPath}/addStudent"><button type="button" class="btn btn-primary">Добавить студента</button></a>
    </div>
</body>
</html>

Ошибка в логе

29-Apr-2019 15:19:31.820 INFO [mysql-cj-abandoned-connection-cleanup] org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
 java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
    at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1383)
    at org.apache.catalina.loader.WebappClassLoaderBase.getResource(WebappClassLoaderBase.java:1036)
    at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.checkThreadContextClassLoader(AbandonedConnectionCleanupThread.java:117)
    at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:84)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
29-Apr-2019 15:19:31.820 INFO [mysql-cj-abandoned-connection-cleanup] org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
 java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
    at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1383)
    at org.apache.catalina.loader.WebappClassLoaderBase.getResource(WebappClassLoaderBase.java:1036)
    at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.checkThreadContextClassLoader(AbandonedConnectionCleanupThread.java:117)
    at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:84)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
29-Apr-2019 15:19:31.883 INFO [mysql-cj-abandoned-connection-cleanup] org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
 java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
    at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1383)
    at org.apache.catalina.loader.WebappClassLoaderBase.getResource(WebappClassLoaderBase.java:1036)
    at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.checkThreadContextClassLoader(AbandonedConnectionCleanupThread.java:117)
    at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:84)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
READ ALSO
вывод случайного byte[] в Java

вывод случайного byte[] в Java

Помогите разобраться, пожалуйста!

129
Как распечатать JPanel?

Как распечатать JPanel?

Пишу программу по учету заказов одного предприятияЕсть форма, которая по сути есть отчет, то есть на нее добавляется различная информация

151
Как в Intellij IDEA открыть 2 проекта сразу

Как в Intellij IDEA открыть 2 проекта сразу

Мне нужно открыть одновременно 2 проекта в Intellij IDEA в двух разных окнах, но чего-то я никак не соображу, как это сделать, подскажите, пожалуйста!

550
adb повреждает копируемый архив

adb повреждает копируемый архив

Программа на Android устройстве пакует файлы из /files/ в архивНеобходимо извлекать архив с помощью adb (другая программа на ПК должна будет запустить...

109