Tomcat's boot profile is Tomcat/conf/server.xml, and a service is configured by default:
<?xml version= "1.0" encoding= "UTF-8"? ><server port= "8005" shutdown= "shutdown" > <listener classname= " Org.apache.catalina.startup.VersionLoggerListener "/> <listener classname=" Org.apache.catalina.core.AprLifecycleListener "sslengine=" on "/> <listener classname=" Org.apache.catalina.core.JreMemoryLeakPreventionListener "/> <listener classname=" Org.apache.catalina.mbeans.GlobalResourcesLifecycleListener "/> <listener classname=" Org.apache.catalina.core.ThreadLocalLeakPreventionListener "/> <GlobalNamingResources> <resource name= "Userdatabase" auth= "Container" type= "Org.apache.catalina.UserDatabase" description= "User Databa SE, can be updated and saved "factory=" Org.apache.catalina.users.MemoryUserDatabaseFactory " Pathname= "Conf/tomcat-users.xml"/> </GlobalNamingResources> <service name= "Catalina" > <connector port= "8080" protocol= "http/1.1" connectiontimeout= "20000" redirectport= "8443"/> <connector port= "8009" protocol= "AJP/1.3" redir ectport= "8443"/> <engine name= "Catalina" defaulthost= "localhost" > <realm classname= "Org.apache.catali Na.realm.LockOutRealm "> <realm classname=" Org.apache.catalina.realm.UserDatabaseRealm "Resource Name= "Userdatabase"/> </Realm>
Of course, the context element inside the host is my Config Web project Plus, the Docbase property value points to the Web app that needs to be started, the value of the Path property specifies the path namespace to access, and I'm accustomed to the empty string
<Context docBase="" path="" />
Now requires two applications, need to configure a service, need to ensure that the Service Name property is not the same, while guaranteeing two child elements connector HTTP port and AJP listening port does not conflict with the port of the previous application
Another service configuration is added as follows,
<Service name="ZeroHome"> <Connector port="8088" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8444" /> <Connector port="8010" protocol="AJP/1.3" redirectPort="8443" /> <Engine name="Catalina" defaultHost="localhost"> <Realm className="org.apache.catalina.realm.LockOutRealm"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> <Context docBase="" path="" /> </Host> </Engine> </Service>
However, two Web apps did start up, and observing log files had an error message.
SEVERE: Creation of the naming context failed: [javax.naming.OperationNotSupportedException: Context is read only]
After trying a few times, I found out
After changing the Engine element's Name property to be different from the first one, the error disappears and the two Web launch succeeds.
<Engine name="Catalina2" defaultHost="localhost">
The specific reason for the error is still looking for
Tomcat launches multiple ports for multiple Web applications