启动tomcat报500错误

启动tomcat报500错误

D:\tomcat\apache-tomcat-8.5.37\bin\catalina.bat run

[2019-03-13 10:34:42,941] Artifact JDBCMessageBoard:war exploded: Waiting for server connection to start artifact deployment...

Using CATALINA_BASE:   "C:\Users\Administrator\.IntelliJIdea2018.3\system\tomcat\Unnamed_JDBCMessageBoard"

Using CATALINA_HOME:   "D:\tomcat\apache-tomcat-8.5.37"

Using CATALINA_TMPDIR: "D:\tomcat\apache-tomcat-8.5.37\temp"

Using JRE_HOME:        "D:\java\jdk"

Using CLASSPATH:       "D:\tomcat\apache-tomcat-8.5.37\bin\bootstrap.jar;D:\tomcat\apache-tomcat-8.5.37\bin\tomcat-juli.jar"

13-Mar-2019 22:34:44.814 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.5.37

13-Mar-2019 22:34:44.820 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Dec 12 2018 12:07:02 UTC

13-Mar-2019 22:34:44.821 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.5.37.0

13-Mar-2019 22:34:44.821 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Windows 10

13-Mar-2019 22:34:44.821 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            10.0

13-Mar-2019 22:34:44.822 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64

13-Mar-2019 22:34:44.822 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             D:\java\jdk\jre

13-Mar-2019 22:34:44.823 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_112-b15

13-Mar-2019 22:34:44.823 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation

13-Mar-2019 22:34:44.823 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         C:\Users\Administrator\.IntelliJIdea2018.3\system\tomcat\Unnamed_JDBCMessageBoard

13-Mar-2019 22:34:44.823 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         D:\tomcat\apache-tomcat-8.5.37

13-Mar-2019 22:34:44.824 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\Administrator\.IntelliJIdea2018.3\system\tomcat\Unnamed_JDBCMessageBoard\conf\logging.properties

13-Mar-2019 22:34:44.825 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

13-Mar-2019 22:34:44.825 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=

13-Mar-2019 22:34:44.825 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099

13-Mar-2019 22:34:44.829 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false

13-Mar-2019 22:34:44.830 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false

13-Mar-2019 22:34:44.830 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1

13-Mar-2019 22:34:44.830 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048

13-Mar-2019 22:34:44.830 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources

13-Mar-2019 22:34:44.831 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=

13-Mar-2019 22:34:44.831 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\Administrator\.IntelliJIdea2018.3\system\tomcat\Unnamed_JDBCMessageBoard

13-Mar-2019 22:34:44.831 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=D:\tomcat\apache-tomcat-8.5.37

13-Mar-2019 22:34:44.832 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=D:\tomcat\apache-tomcat-8.5.37\temp

13-Mar-2019 22:34:44.832 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library [1.2.19] using APR version [1.6.5].

13-Mar-2019 22:34:44.832 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].

13-Mar-2019 22:34:44.832 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]

13-Mar-2019 22:34:44.841 信息 [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1a  20 Nov 2018]

13-Mar-2019 22:34:45.101 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8888"]

13-Mar-2019 22:34:45.129 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read

13-Mar-2019 22:34:45.152 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]

13-Mar-2019 22:34:45.163 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read

13-Mar-2019 22:34:45.164 信息 [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1239 ms

13-Mar-2019 22:34:45.222 信息 [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]

13-Mar-2019 22:34:45.222 信息 [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.37

13-Mar-2019 22:34:45.237 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8888"]

13-Mar-2019 22:34:45.249 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]

13-Mar-2019 22:34:45.255 信息 [main] org.apache.catalina.startup.Catalina.start Server startup in 90 ms

Connected to server

[2019-03-13 10:34:45,262] Artifact JDBCMessageBoard:war exploded: Artifact is being deployed, please wait...

13-Mar-2019 22:34:45.699 警告 [RMI TCP Connection(5)-127.0.0.1] org.apache.tomcat.util.descriptor.web.WebXml.setVersion Unknown version string [4.0]. Default version will be used.

13-Mar-2019 22:34:46.692 信息 [RMI TCP Connection(5)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

[2019-03-13 10:34:46,792] Artifact JDBCMessageBoard:war exploded: Artifact is deployed successfully

[2019-03-13 10:34:46,792] Artifact JDBCMessageBoard:war exploded: Deploy took 1,530 milliseconds

13-Mar-2019 22:34:55.239 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [D:\tomcat\apache-tomcat-8.5.37\webapps\manager]

13-Mar-2019 22:34:55.351 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [D:\tomcat\apache-tomcat-8.5.37\webapps\manager] has finished in [110] ms


<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019-03-13
  Time: 14:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>$Title$</title>
    <meta http-equiv="refresh" content="0;url=<%=request.getContextPath()%>/message/list.do">
  </head>
  <body>

  </body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
    <welcome-file-list>
        <welcome-file>/index.jsp</welcome-file>
    </welcome-file-list>
    <error-page>
        <error-code>404</error-code>
        <location>/WEB-INF/views/error/404.jsp</location>
    </error-page>
    <error-page>
        <error-code>500</error-code>
        <location>/WEB-INF/views/error/500.jsp</location>
    </error-page>
    <servlet>
        <servlet-name>messageListServlet</servlet-name>
        <servlet-class>com.imooc.jdbc.servlet.MessageListServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>messageListServlet</servlet-name>
        <url-pattern>/message/list.do</url-pattern>
    </servlet-mapping>
</web-app>
package com.imooc.jdbc.servlet;

import com.imooc.jdbc.bean.Message;
import com.imooc.jdbc.service.MessageService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;


public class MessageListServlet extends HttpServlet {

    private MessageService messageService;

    @Override
    public void init() throws ServletException {
        super.init();
        messageService = new MessageService();
    }

    @Override
    public void destroy() {
        super.destroy();
        messageService = null;
    }

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String pageStr = request.getParameter("page");//当前页码
        int page = 1;//页码默认值为1
        if (pageStr != null && "".equals(pageStr)) {
            try {
                page = Integer.parseInt(pageStr);
            } catch (NumberFormatException e) {
                e.printStackTrace();
            }
        }
        List<Message> messages = messageService.getMessages(page, 5);//分页查询全部留言
        int count = messageService.countMessages();//留言数量
        int last = count % 5 == 0 ? (count / 5) : ((count / 5) + 1);//最后的页码
        request.setAttribute("last", last);
        request.setAttribute("messages", messages);
        request.setAttribute("page", page);
        request.getRequestDispatcher("/WEB-INF/views/biz/message_list.jsp").forward(request, response);
    }
}

http://img1.sycdn.imooc.com//climg/5c89167e0001d28d08190120.jpg

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

4回答
提问者 给大佬递茶 2019-03-14 17:12:33

问题已经找到,一个是jsp中文乱码问题,在头部加上pageEncoding=utf-8

还是就是Message的username属性,我用的驼峰命名写成userName

chrismorgen 2019-03-14 16:25:56

你好同学,请问你启动项目之前的报错信息是什么呢?建议你将错误500的信息粘贴上来,方便老师具有针对性的为你解答,祝学习愉快~

  • 提问者 给大佬递茶 #1
    启动项目之前没报错,500的信息问题里有图片,message_list.jsp是复制老师的。 servlet里跳转到message_list.jsp失败,可以调到其他jsp,而且message_list.jsp里 <% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; pageContext.setAttribute("basePath", basePath); %> setAttribute标红
    2019-03-14 17:03:28
慕布斯645313 2019-03-14 10:35:47

你启动的时候粘贴的不是报错信息呀,你关闭之后出现了报错,你看一下这个博客的解决方法。https://blog.csdn.net/weigao_easy/article/details/51833470

  • 提问者 给大佬递茶 #1
    不是这个的问题,如果按这帖子做那就没有热部署了
    2019-03-14 11:16:55
提问者 给大佬递茶 2019-03-13 22:43:24

D:\tomcat\apache-tomcat-8.5.37\bin\catalina.bat stop

Using CATALINA_BASE:   "C:\Users\Administrator\.IntelliJIdea2018.3\system\tomcat\Unnamed_JDBCMessageBoard"

Using CATALINA_HOME:   "D:\tomcat\apache-tomcat-8.5.37"

Using CATALINA_TMPDIR: "D:\tomcat\apache-tomcat-8.5.37\temp"

Using JRE_HOME:        "D:\java\jdk"

Using CLASSPATH:       "D:\tomcat\apache-tomcat-8.5.37\bin\bootstrap.jar;D:\tomcat\apache-tomcat-8.5.37\bin\tomcat-juli.jar"

13-Mar-2019 22:41:16.647 信息 [main] org.apache.catalina.core.StandardServer.await A valid shutdown command was received via the shutdown port. Stopping the Server instance.

13-Mar-2019 22:41:16.648 信息 [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-8888"]

13-Mar-2019 22:41:16.889 信息 [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["ajp-nio-8009"]

13-Mar-2019 22:41:17.097 信息 [main] org.apache.catalina.core.StandardService.stopInternal Stopping service [Catalina]

13-Mar-2019 22:41:17.108 警告 [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [message] registered the JDBC driver [com.mysql.cj.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

13-Mar-2019 22:41:17.109 警告 [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [message] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:

 java.lang.Object.wait(Native Method)

 java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)

 com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:70)

 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

 java.lang.Thread.run(Thread.java:745)

13-Mar-2019 22:41:17.120 信息 [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8888"]

13-Mar-2019 22:41:17.122 信息 [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-nio-8009"]

13-Mar-2019 22:41:17.139 信息 [Abandoned connection cleanup thread] 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:1364)

at org.apache.catalina.loader.WebappClassLoaderBase.getResource(WebappClassLoaderBase.java:1021)

at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.checkContextClassLoaders(AbandonedConnectionCleanupThread.java:96)

at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:69)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)


13-Mar-2019 22:41:17.144 信息 [Abandoned connection cleanup thread] 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:1364)

at org.apache.catalina.loader.WebappClassLoaderBase.getResource(WebappClassLoaderBase.java:1021)

at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.checkContextClassLoaders(AbandonedConnectionCleanupThread.java:96)

at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:69)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)


13-Mar-2019 22:41:17.144 信息 [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8888"]

13-Mar-2019 22:41:17.147 信息 [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-nio-8009"]

Disconnected from server


  • 提问者 给大佬递茶 #1
    这是停止tomcat后报的错
    2019-03-13 22:44:26
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
Java数据库开发与实战应用2018版
  • 参与学习           人
  • 提交作业       277    份
  • 解答问题       4297    个

Java数据库开发的必备技能,从流行的MySQL数据库开始,到Java原生的数据库管理接口JDBC的使用,再到常用的数据持久化框架MyBatis,让你向Java工程师的目标又迈进了一步!

了解课程
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师