怎么让cmd命令行不关闭或查看tomcat启动一闪而过的原因

场景:在运行tomcat的时候或者其他的bat文件,想保持cmd命令行窗口一直打开,以便查看里面的信息

现在你有一个startup.bat命令行文件,一般情况下正常启动是可以一直显示cmd命令行窗口的,但是由于有些原因导致异常,一闪而过,怎么让cmd命令行一直保持以便看到里面的异常信息呢,我找到有2种方法:

 

  1. 打开命令行窗口,用命令进入你的bat文件所在目录,cd D:\apache-tomcat-7.0.57\bin,然后输入startup.bat然后回车就可以了,或者直接在运行里输入cmd /k D:\apache-tomcat-7.0.57\bin\startup.bat然后回车就可以了,这样命令行就一直存在了
  2. 右键用记事本打开startup.bat,在末尾加一行pause或者cmd /k,然后保存,再双击,命令行就一直存在了
这个还是挺常用的,记一笔。
 
2020.01.10更新
或者可以直接查看catalina日志: tomcat根目录下的logs文件夹内
如我的会有此文件: apache-tomcat-8.5.32\logs\catalina.2020-01-10.log

 

10-Jan-2020 21:23:15.941 警告 [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:dev' did not find a matching property.
10-Jan-2020 21:23:15.963 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.5.32
10-Jan-2020 21:23:15.970 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jun 20 2018 19:50:35 UTC
10-Jan-2020 21:23:15.974 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.5.32.0
10-Jan-2020 21:23:15.978 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Windows 7
10-Jan-2020 21:23:15.979 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            6.1
10-Jan-2020 21:23:15.982 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
10-Jan-2020 21:23:15.988 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             C:\download\java\jdk1.8.0_111\jre
10-Jan-2020 21:23:15.992 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_111-b14
10-Jan-2020 21:23:15.997 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
10-Jan-2020 21:23:16.003 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         D:\tools\apache-tomcat-8.5.32
10-Jan-2020 21:23:16.008 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         D:\tools\apache-tomcat-8.5.32
10-Jan-2020 21:23:16.012 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=D:\tools\apache-tomcat-8.5.32\conf\logging.properties
10-Jan-2020 21:23:16.016 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
10-Jan-2020 21:23:16.020 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
10-Jan-2020 21:23:16.025 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
10-Jan-2020 21:23:16.030 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
10-Jan-2020 21:23:16.036 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=D:\tools\apache-tomcat-8.5.32
10-Jan-2020 21:23:16.040 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=D:\tools\apache-tomcat-8.5.32
10-Jan-2020 21:23:16.045 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=D:\tools\apache-tomcat-8.5.32\temp
10-Jan-2020 21:23:16.050 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\download\java\jdk1.8.0_111\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\IDM Computer Solutions\UltraEdit;C:\download\java\jdk1.8.0_111\bin;C:\download\java\jdk1.8.0_111\jre\bin;C:\download\java\apache\apache-maven-3.3.9\bin;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\nodejs;C:\Program Files (x86)\SSH Communications Security\SSH Secure Shell;C:\Users\01\AppData\Roaming\npm;D:\xfj\BeX5_V3.7\tools\adt-sdk\platform-tools;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Bandizip\;C:\Users\01\AppData\Local\Yarn\bin;.]
10-Jan-2020 21:23:16.263 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8081"]
10-Jan-2020 21:23:16.790 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
10-Jan-2020 21:23:16.802 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8008"]
10-Jan-2020 21:23:16.821 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
10-Jan-2020 21:23:16.825 信息 [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1604 ms
10-Jan-2020 21:23:16.869 信息 [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
10-Jan-2020 21:23:16.874 信息 [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.32
10-Jan-2020 21:23:16.917 严重 [Catalina-startStop-1] org.apache.catalina.core.ContainerBase.startInternal A child container failed during start
 java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/dev]]
	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	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)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/dev]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
	... 6 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@71f4d907]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
	at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4907)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5042)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	... 6 more
Caused by: java.lang.IllegalArgumentException: The main resource set specified [D:\tools\apache-tomcat-8.5.32\webapps\dev] is not valid
	at org.apache.catalina.webresources.StandardRoot.createMainResourceSet(StandardRoot.java:748)
	at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:706)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	... 9 more

10-Jan-2020 21:23:16.928 严重 [main] org.apache.catalina.core.ContainerBase.startInternal A child container failed during start
 java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:681)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	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)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:949)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	... 6 more

10-Jan-2020 21:23:16.939 严重 [main] org.apache.catalina.startup.Catalina.start The required Server component failed to start so Tomcat is unable to start.
 org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8006]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:681)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	... 9 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:949)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	... 11 more

10-Jan-2020 21:23:16.948 信息 [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-8081"]
10-Jan-2020 21:23:16.952 信息 [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["ajp-nio-8008"]
10-Jan-2020 21:23:16.958 信息 [main] org.apache.catalina.core.StandardService.stopInternal Stopping service [Catalina]
10-Jan-2020 21:23:16.966 信息 [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8081"]
10-Jan-2020 21:23:16.973 信息 [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-nio-8008"]

出现这个错误是因为我把tomcat下的webapps里面的dev项目删除了,但是没有删除conf\server.xml里的context配置导致,



       ...

  


还有没有删除work\Catalina\localhost里面的dev文件夹

究其原因,是因为在eclipse新建tomcat配置项目部署的时候,没有选择以独立xml文件发布的形式,导致配置写在server.xml里面,当删除项目的时候,没有连带删除,因此建议发布以独立xml形式进行发布.

怎么让cmd命令行不关闭或查看tomcat启动一闪而过的原因_第1张图片

 

你可能感兴趣的:(命令行,bat,cmd)