配置tomcat中的server.xml时遇到问题,会导致tomcat启动闪退。
server.xml文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<!-- Security listener. Documentation at /docs/config/listeners.html
<Listener className="org.apache.catalina.security.SecurityListener" />
-->
<!-- APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina">
<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
-->
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
-->
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443"
maxParameterCount="1000"
/>
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
maxParameterCount="1000"
/>
-->
<!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443
This connector uses the NIO implementation. The default
SSLImplementation will depend on the presence of the APR/native
library and the useOpenSSL attribute of the AprLifecycleListener.
Either JSSE or OpenSSL style configuration may be used regardless of
the SSLImplementation selected. JSSE style configuration is used below.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true"
maxParameterCount="1000"
>
<SSLHostConfig>
<Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
type="RSA" />
</SSLHostConfig>
</Connector>
-->
<!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2
This connector uses the APR/native implementation which always uses
OpenSSL for TLS.
Either JSSE or OpenSSL style configuration may be used. OpenSSL style
configuration is used below.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
maxThreads="150" SSLEnabled="true"
maxParameterCount="1000"
>
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
<SSLHostConfig>
<Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
certificateFile="conf/localhost-rsa-cert.pem"
certificateChainFile="conf/localhost-rsa-chain.pem"
type="RSA" />
</SSLHostConfig>
</Connector>
-->
<Connector
protocol="org.apache.coyote.http11.Http11NioProtocol"
port="443" maxThreads="200"
scheme="https" secure="true" SSLEnabled="true"
keystoreFile="conf/prosetechnologies.com.jks" keystorePass="PROSETECH2024-2025"
clientAuth="false" sslProtocol="TLS"/>
<!-- Define an AJP 1.3 Connector on port 8009 -->
<!--
<Connector protocol="AJP/1.3"
address="::1"
port="8009"
redirectPort="8443"
maxParameterCount="1000"
/>
-->
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->
<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" defaultHost="localhost">
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="home" appBase="webapps/home"
unpackWARs="true" autoDeploy="true">
<Context docBase="/ipkiss/apache-tomcat-9.0.85/webapps/home" path="" reloadable="true" ></Context>
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
</Server>
文件中配置两处Host标签,第一处会启动webapps/home项目,第二处会启动webapps下的所有项目,这样会导致home项目启动两次。
查看 catalina.out 证明home启动了两次
26-Mar-2024 21:00:27.360 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/9.0.85
26-Mar-2024 21:00:27.362 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jan 5 2024 08:28:07 UTC
26-Mar-2024 21:00:27.363 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.85.0
26-Mar-2024 21:00:27.363 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
26-Mar-2024 21:00:27.363 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 5.15.0-76-generic
26-Mar-2024 21:00:27.363 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
26-Mar-2024 21:00:27.363 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /ipkiss/java/jdk1.8.0_192/jre
26-Mar-2024 21:00:27.363 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_192-b12
26-Mar-2024 21:00:27.363 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
26-Mar-2024 21:00:27.363 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /ipkiss/apache-tomcat-9.0.85
26-Mar-2024 21:00:27.363 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /ipkiss/apache-tomcat-9.0.85
26-Mar-2024 21:00:27.380 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/ipkiss/apache-tomcat-9.0.85/conf/logging.properties
26-Mar-2024 21:00:27.380 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
26-Mar-2024 21:00:27.380 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
26-Mar-2024 21:00:27.382 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
26-Mar-2024 21:00:27.382 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
26-Mar-2024 21:00:27.382 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
26-Mar-2024 21:00:27.382 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/ipkiss/apache-tomcat-9.0.85
26-Mar-2024 21:00:27.382 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/ipkiss/apache-tomcat-9.0.85
26-Mar-2024 21:00:27.382 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/ipkiss/apache-tomcat-9.0.85/temp
26-Mar-2024 21:00:27.387 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The Apache Tomcat Native library which allows using OpenSSL was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
26-Mar-2024 21:00:28.118 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-80"]
26-Mar-2024 21:00:28.157 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["https-jsse-nio-443"]
26-Mar-2024 21:00:28.442 SEVERE [main] org.apache.catalina.util.LifecycleBase.handleSubClassException Failed to initialize component [Connector["https-jsse-nio-443"]]
org.apache.catalina.LifecycleException: Protocol handler initialization failed
at org.apache.catalina.connector.Connector.initInternal(Connector.java:1011)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:127)
at org.apache.catalina.core.StandardService.initInternal(StandardService.java:554)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:127)
at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:1039)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:127)
at org.apache.catalina.startup.Catalina.load(Catalina.java:724)
at org.apache.catalina.startup.Catalina.load(Catalina.java:746)
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.load(Bootstrap.java:307)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:477)
Caused by: java.lang.IllegalArgumentException: /ipkiss/apache-tomcat-9.0.85/conf/prosetechnologies.com.jks (No such file or directory)
at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:107)
at org.apache.tomcat.util.net.AbstractJsseEndpoint.initialiseSsl(AbstractJsseEndpoint.java:71)
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:236)
at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1332)
at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:1345)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:654)
at org.apache.coyote.http11.AbstractHttp11Protocol.init(AbstractHttp11Protocol.java:75)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:1009)
... 13 more
Caused by: java.io.FileNotFoundException: /ipkiss/apache-tomcat-9.0.85/conf/prosetechnologies.com.jks (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
at org.apache.catalina.startup.CatalinaBaseConfigurationSource.getResource(CatalinaBaseConfigurationSource.java:118)
at org.apache.tomcat.util.net.SSLUtilBase.getStore(SSLUtilBase.java:210)
at org.apache.tomcat.util.net.SSLHostConfigCertificate.getCertificateKeystore(SSLHostConfigCertificate.java:237)
at org.apache.tomcat.util.net.SSLUtilBase.getKeyManagers(SSLUtilBase.java:308)
at org.apache.tomcat.util.net.SSLUtilBase.createSSLContext(SSLUtilBase.java:268)
at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:105)
... 20 more
26-Mar-2024 21:00:28.446 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [1505] milliseconds
26-Mar-2024 21:00:28.488 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
26-Mar-2024 21:00:28.489 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.85]
26-Mar-2024 21:00:28.505 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/ipkiss/apache-tomcat-9.0.85/webapps/home.war]
26-Mar-2024 21:00:31.971 INFO [main] 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.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.5.RELEASE)
2024-03-26 21:00:33.056 INFO 825386 --- [ main] com.prose.home.ServletInitializer : Starting ServletInitializer v0.0.1-SNAPSHOT on hecs-283154 with PID 825386 (/ipkiss/apache-tomcat-9.0.85/webapps/home/WEB-INF/classes started by root in /ipkiss/apache-tomcat-9.0.85/bin)
2024-03-26 21:00:33.066 INFO 825386 --- [ main] com.prose.home.ServletInitializer : No active profile set, falling back to default profiles: default
2024-03-26 21:00:35.673 INFO 825386 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2219 ms
2024-03-26 21:00:37.733 INFO 825386 --- [ main] .s.s.UserDetailsServiceAutoConfiguration :
Using generated security password: a53c8849-b83e-43f5-a67b-e2dae34639f3
2024-03-26 21:00:37.880 INFO 825386 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: Ant [pattern='/static/**'], []
2024-03-26 21:00:37.975 INFO 825386 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@756fd0aa, org.springframework.security.web.context.SecurityContextPersistenceFilter@7c5f244c, org.springframework.security.web.header.HeaderWriterFilter@3f31ff7a, org.springframework.web.filter.CorsFilter@1a9ea4d9, org.springframework.security.web.authentication.logout.LogoutFilter@7e7c780, org.springframework.security.web.session.ConcurrentSessionFilter@686aa9c9, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@77cfbbba, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@3be76b8d, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@59ca0db6, org.springframework.security.web.session.SessionManagementFilter@6593f4fd, org.springframework.security.web.access.ExceptionTranslationFilter@32eb46d7]
2024-03-26 21:00:38.535 INFO 825386 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'taskScheduler'
2024-03-26 21:00:38.623 INFO 825386 --- [ main] com.prose.home.ServletInitializer : Started ServletInitializer in 6.352 seconds (JVM running for 12.065)
26-Mar-2024 21:00:38.673 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/ipkiss/apache-tomcat-9.0.85/webapps/home.war] has finished in [10,168] ms
26-Mar-2024 21:00:38.675 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/ipkiss/apache-tomcat-9.0.85/webapps/examples]
26-Mar-2024 21:00:39.013 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/ipkiss/apache-tomcat-9.0.85/webapps/examples] has finished in [338] ms
26-Mar-2024 21:00:39.013 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/ipkiss/apache-tomcat-9.0.85/webapps/docs]
26-Mar-2024 21:00:39.033 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/ipkiss/apache-tomcat-9.0.85/webapps/docs] has finished in [20] ms
26-Mar-2024 21:00:39.033 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/ipkiss/apache-tomcat-9.0.85/webapps/ROOT]
26-Mar-2024 21:00:39.052 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/ipkiss/apache-tomcat-9.0.85/webapps/ROOT] has finished in [19] ms
26-Mar-2024 21:00:39.053 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/ipkiss/apache-tomcat-9.0.85/webapps/host-manager]
26-Mar-2024 21:00:39.084 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/ipkiss/apache-tomcat-9.0.85/webapps/host-manager] has finished in [31] ms
26-Mar-2024 21:00:39.085 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/ipkiss/apache-tomcat-9.0.85/webapps/manager]
26-Mar-2024 21:00:39.114 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/ipkiss/apache-tomcat-9.0.85/webapps/manager] has finished in [28] ms
26-Mar-2024 21:00:41.769 INFO [main] 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.
26-Mar-2024 21:00:41.827 INFO [main] org.apache.catalina.core.ApplicationContext.log 2 Spring WebApplicationInitializers detected on classpath
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.5.RELEASE)
2024-03-26 21:00:42.596 INFO 825386 --- [ main] com.prose.home.ServletInitializer : Starting ServletInitializer v0.0.1-SNAPSHOT on hecs-283154 with PID 825386 (/ipkiss/apache-tomcat-9.0.85/webapps/home/WEB-INF/classes started by root in /ipkiss/apache-tomcat-9.0.85/bin)
2024-03-26 21:00:42.605 INFO 825386 --- [ main] com.prose.home.ServletInitializer : No active profile set, falling back to default profiles: default
26-Mar-2024 21:00:44.882 INFO [main] org.apache.catalina.core.ApplicationContext.log Initializing Spring embedded WebApplicationContext
2024-03-26 21:00:44.882 INFO 825386 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1952 ms
2024-03-26 21:00:46.824 INFO 825386 --- [ main] .s.s.UserDetailsServiceAutoConfiguration :
Using generated security password: b3912e8b-a0d6-4584-b4a3-0c0421d0279f
2024-03-26 21:00:46.928 INFO 825386 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: Ant [pattern='/static/**'], []
2024-03-26 21:00:47.041 INFO 825386 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@69b29de2, org.springframework.security.web.context.SecurityContextPersistenceFilter@77fa7d98, org.springframework.security.web.header.HeaderWriterFilter@99ee4f1, org.springframework.web.filter.CorsFilter@3627e490, org.springframework.security.web.authentication.logout.LogoutFilter@3ed71a9a, org.springframework.security.web.session.ConcurrentSessionFilter@2bcd4f3d, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@6df04f36, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@63e05408, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@321209b5, org.springframework.security.web.session.SessionManagementFilter@264c6a50, org.springframework.security.web.access.ExceptionTranslationFilter@d97c869]
2024-03-26 21:00:47.619 INFO 825386 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'taskScheduler'
2024-03-26 21:00:47.724 INFO 825386 --- [ main] com.prose.home.ServletInitializer : Started ServletInitializer in 5.737 seconds (JVM running for 21.165)
26-Mar-2024 21:00:47.745 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-80"]
26-Mar-2024 21:00:47.786 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [19340] milliseconds
2024-03-26 21:00:49.747 INFO 825386 --- [p-nio-80-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2024-03-26 21:00:49.762 INFO 825386 --- [p-nio-80-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 14 ms
在日志中可以看到没有报错,但如果home项目中,会开启一个端口,在第二处Host标签启动时,会出现ERROR,提示信息:端口号被占用(这里其实是因为第一处Host启动项目时,就已经占用了端口),随后tomcat会关闭。
所有在配置server.xml时,需要注意添加以下代码是否会导致端口号冲突等异常问题。
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
tomcat9.0.31配置 .jks证书
第一步:将8080端口的代码修改为如下:
<!-- 将8080修改为80,端口重映射到443端口-->
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />
在server.xml中添加以下代码:
<Connector
protocol="org.apache.coyote.http11.Http11NioProtocol"
port="443" maxThreads="200"
scheme="https" secure="true" SSLEnabled="true"
keystoreFile="/path/to/***.jks"
keystorePass="密码"
clientAuth="false" sslProtocol="TLS"/>
配置域名映射关系
在server.xml中添加以下代码:
<Host name="www.xxxxxx.com" appBase="webapps/home"
unpackWARs="true" autoDeploy="true">
<Context docBase="/usr/local/apache-tomcat-9.0.31/webapps/home" path="" reloadable="true" ></Context>
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
Host标签
- name:域名 网址
- appBase:项目的路径
Context标签
- docBase:项目的路径
- path: Web 应用程序的路径,如果path设置为 /app 则需要通过 www.xxxxxx.com/app 访问