- 浏览: 981170 次
文章分类
- 全部博客 (428)
- Hadoop (2)
- HBase (1)
- ELK (1)
- ActiveMQ (13)
- Kafka (5)
- Redis (14)
- Dubbo (1)
- Memcached (5)
- Netty (56)
- Mina (34)
- NIO (51)
- JUC (53)
- Spring (13)
- Mybatis (17)
- MySQL (21)
- JDBC (12)
- C3P0 (5)
- Tomcat (13)
- SLF4J-log4j (9)
- P6Spy (4)
- Quartz (12)
- Zabbix (7)
- JAVA (9)
- Linux (15)
- HTML (9)
- Lucene (0)
- JS (2)
- WebService (1)
- Maven (4)
- Oracle&MSSQL (14)
- iText (11)
- Development Tools (8)
- UTILS (4)
- LIFE (8)
最新评论
-
Donald_Draper:
Donald_Draper 写道刘落落cici 写道能给我发一 ...
DatagramChannelImpl 解析三(多播) -
Donald_Draper:
刘落落cici 写道能给我发一份这个类的源码吗Datagram ...
DatagramChannelImpl 解析三(多播) -
lyfyouyun:
请问楼主,执行消息发送的时候,报错:Transport sch ...
ActiveMQ连接工厂、连接详解 -
ezlhq:
关于 PollArrayWrapper 状态含义猜测:参考 S ...
WindowsSelectorImpl解析一(FdMap,PollArrayWrapper) -
flyfeifei66:
打算使用xmemcache作为memcache的客户端,由于x ...
Memcached分布式客户端(Xmemcached)
Tomcat 系统架构与设计模式,工作原理:http://www.ibm.com/developerworks/cn/java/j-lo-tomcat1/
Tomcat 系统架构与设计模式,设计模式分析:http://www.ibm.com/developerworks/cn/java/j-lo-tomcat2/
Tomcat启动脚本catalina.sh:http://www.xuebuyuan.com/1361490.html
Tomcat学习笔记之catalina.sh:http://www.tuicool.com/articles/fuAnEn3
查看Tomcat的启动过程,我们首先从startup.sh开始看起:
首先查看startup.sh
查看catalina.sh脚本文件:
关键在这一句: org.apache.catalina.startup.Bootstrap "$@" start
此句的意义在于启动tomcat的类是org.apache.catalina.startup.Bootstrap.main("start");
下面我们来看Bootstrap :
//Catalina
//Digester
总结:
从以上分析,可以得出startup.sh实际,确定catalina.sh的目录,及是否有执行权限,在执行catalina.sh;而Catalina.sh所做的事情实际上是,初始化Catalina,home以及base目录,初始化JVM参数,执行Bootstrap的main(String[]{start))函数,Bootstrap的main函数,也就是tomcat的启动入口。Bootstrap的main(),执行初始化类加载器,设置catalina,home和base目录,设置当前线程的ClassLoader,新建Catalina实例,设置Catalina的父加载器(setParentClassLoader);通过反射获取Catalina的catalina.setAwait方法,设置为等待状态标识(daemon.setAwait(true);),调用catalina.load函数,初始化Server,目录,命名空间等(daemon.load(args);),调用catalina.start函数启动Server。后面Catalina.start()所做的事情(StandardServer,StandardService,
StandardEngin,StandardHost,Wrapper(StandardWrapper),StandardContext,StandardContainer,Connector),我们在后续文章中,再分析。
Tomcat的Server初始化及启动过程:http://donald-draper.iteye.com/admin/blogs/2327060
附:Serve.xml
Tomcat 系统架构与设计模式,设计模式分析:http://www.ibm.com/developerworks/cn/java/j-lo-tomcat2/
Tomcat启动脚本catalina.sh:http://www.xuebuyuan.com/1361490.html
Tomcat学习笔记之catalina.sh:http://www.tuicool.com/articles/fuAnEn3
查看Tomcat的启动过程,我们首先从startup.sh开始看起:
首先查看startup.sh
####解决catalina.sh目录问题 # resolve links - $0 may be a softlink PRG="$0" while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`/"$link" fi done PRGDIR=`dirname "$PRG"` ###############shell 脚本文件 EXECUTABLE=catalina.sh # Check that target executable exists if $os400; then # -x will Only work on the os400 if the files are: # 1. owned by the user # 2. owned by the PRIMARY group of the user # this will not work if the user belongs in secondary groups eval else if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then echo "Cannot find $PRGDIR/$EXECUTABLE" echo "The file is absent or does not have execute permission" echo "This file is needed to run this program" exit 1 fi fi ###############执行shell脚本文件 exec "$PRGDIR"/"$EXECUTABLE" start "$@"
查看catalina.sh脚本文件:
# +----------------------------------------------------+ # | ......当执行catalina.sh的参数是start的时候...... | # | 在新窗口中启动tomcat服务器!!! | # +----------------------------------------------------+ elif [ "$1" = "start" ] ; then # 把参数start去掉 shift # 创建一个文件(如果文件不存在的话)$CATALINA_BASE/logs/catalina.out #catalina.sh start -security # 如果参数是start -security,则启动Security Manager if [ "$1" = "-security" ] ; then echo "Using Security Manager" shift "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS \ -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ -Djava.security.manager \ -Djava.security.policy=="$CATALINA_BASE"/conf/catalina.policy \ -Dcatalina.base="$CATALINA_BASE" \ -Dcatalina.home="$CATALINA_HOME" \ -Djava.io.tmpdir="$CATALINA_TMPDIR" \ org.apache.catalina.startup.Bootstrap "$@" start \ >> "$CATALINA_BASE"/logs/catalina.out 2>&1 & if [ ! -z "$CATALINA_PID" ]; then echo $! > $CATALINA_PID fi # 如果参数是孤单的start,那么在新窗口中启动tomcat #catalina.sh start else "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS \ -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ -Dcatalina.base="$CATALINA_BASE" \ -Dcatalina.home="$CATALINA_HOME" \ -Djava.io.tmpdir="$CATALINA_TMPDIR" \ org.apache.catalina.startup.Bootstrap "$@" start \ >> "$CATALINA_BASE"/logs/catalina.out 2>&1 & if [ ! -z "$CATALINA_PID" ]; then echo $! > $CATALINA_PID fi fi
关键在这一句: org.apache.catalina.startup.Bootstrap "$@" start
此句的意义在于启动tomcat的类是org.apache.catalina.startup.Bootstrap.main("start");
下面我们来看Bootstrap :
public final class Bootstrap { /** * Daemon object used by main. */ private static Bootstrap daemon = null; /** * Daemon reference.Catalian实例 */ private Object catalinaDaemon = null; ClassLoader commonLoader = null; ClassLoader catalinaLoader = null; ClassLoader sharedLoader = null; public static void main(String args[]) { if (daemon == null) { // Don't set daemon until init() has completed Bootstrap bootstrap = new Bootstrap(); try { //初始化 bootstrap.init(); } catch (Throwable t) { //处理异常 handleThrowable(t); t.printStackTrace(); return; } daemon = bootstrap; } else { // When running as a service the call to stop will be on a new // thread so make sure the correct class loader is used to prevent // a range of class not found exceptions. Thread.currentThread().setContextClassLoader(daemon.catalinaLoader); } try { String command = "start"; if (args.length > 0) { command = args[args.length - 1]; } if (command.equals("startd")) { args[args.length - 1] = "start"; daemon.load(args); daemon.start(); } else if (command.equals("stopd")) { args[args.length - 1] = "stop"; daemon.stop(); } else if (command.equals("start")) { //实际上调用catalina.setAwait方法,设置为等待状态标识 daemon.setAwait(true); //调用catalina.load函数,初始化Server,目录,命名空间等 daemon.load(args); //调用catalina.start函数启动Server daemon.start(); } else if (command.equals("stop")) { daemon.stopServer(args); } else if (command.equals("configtest")) { daemon.load(args); if (null==daemon.getServer()) { System.exit(1); } System.exit(0); } else { log.warn("Bootstrap: command \"" + command + "\" does not exist."); } } catch (Throwable t) { // Unwrap the Exception for clearer error reporting if (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } handleThrowable(t); t.printStackTrace(); System.exit(1); } } //初始化BootStrap public void init() throws Exception { // Set Catalina path setCatalinaHome(); setCatalinaBase(); initClassLoaders(); //设置当前线程的类加载器 Thread.currentThread().setContextClassLoader(catalinaLoader); SecurityClassLoad.securityClassLoad(catalinaLoader); // Load our startup class and call its process() method if (log.isDebugEnabled()) log.debug("Loading startup class"); Class<?> startupClass = catalinaLoader.loadClass ("org.apache.catalina.startup.Catalina"); //创建Catalina实例 Object startupInstance = startupClass.newInstance(); // Set the shared extensions class loader if (log.isDebugEnabled()) log.debug("Setting startup class properties"); String methodName = "setParentClassLoader"; Class<?> paramTypes[] = new Class[1]; paramTypes[0] = Class.forName("java.lang.ClassLoader"); Object paramValues[] = new Object[1]; paramValues[0] = sharedLoader; //获取Catalina.setParentClassLoader函数 startupInstance.getClass().getMethod(methodName, paramTypes); method.invoke(startupInstance, paramValues); catalinaDaemon = startupInstance; } //设置catalina.home System property to the current private void setCatalinaHome() { if (System.getProperty(Globals.CATALINA_HOME_PROP) != null) return; File bootstrapJar = new File(System.getProperty("user.dir"), "bootstrap.jar"); if (bootstrapJar.exists()) { try { System.setProperty (Globals.CATALINA_HOME_PROP, (new File(System.getProperty("user.dir"), "..")) .getCanonicalPath()); } catch (Exception e) { // Ignore System.setProperty(Globals.CATALINA_HOME_PROP, System.getProperty("user.dir")); } } else { System.setProperty(Globals.CATALINA_HOME_PROP, System.getProperty("user.dir")); } } //设置catalina.base System property to the current private void setCatalinaBase() { if (System.getProperty(Globals.CATALINA_BASE_PROP) != null) return; if (System.getProperty(Globals.CATALINA_HOME_PROP) != null) System.setProperty(Globals.CATALINA_BASE_PROP, System.getProperty(Globals.CATALINA_HOME_PROP)); else System.setProperty(Globals.CATALINA_BASE_PROP, System.getProperty("user.dir")); } //初始化ClassLoaders private void initClassLoaders() { try { commonLoader = createClassLoader("common", null); if( commonLoader == null ) { // no config file, default to this loader - we might be in a 'single' env. commonLoader=this.getClass().getClassLoader(); } catalinaLoader = createClassLoader("server", commonLoader); sharedLoader = createClassLoader("shared", commonLoader); } catch (Throwable t) { handleThrowable(t); log.error("Class loader creation threw exception", t); System.exit(1); } } //创建ClassLoader加载器 private ClassLoader createClassLoader(String name, ClassLoader parent) throws Exception { String value = CatalinaProperties.getProperty(name + ".loader"); if ((value == null) || (value.equals(""))) return parent; value = replace(value); List<Repository> repositories = new ArrayList<Repository>(); StringTokenizer tokenizer = new StringTokenizer(value, ","); while (tokenizer.hasMoreElements()) { String repository = tokenizer.nextToken().trim(); if (repository.length() == 0) { continue; } // Check for a JAR URL repository try { @SuppressWarnings("unused") URL url = new URL(repository); repositories.add( new Repository(repository, RepositoryType.URL)); continue; } catch (MalformedURLException e) { // Ignore } // Local repository if (repository.endsWith("*.jar")) { repository = repository.substring (0, repository.length() - "*.jar".length()); repositories.add( new Repository(repository, RepositoryType.GLOB)); } else if (repository.endsWith(".jar")) { repositories.add( new Repository(repository, RepositoryType.JAR)); } else { repositories.add( new Repository(repository, RepositoryType.DIR)); } } return ClassLoaderFactory.createClassLoader(repositories, parent); } //实际上调用catalina.setAwait方法,设置为等待状态标识 public void setAwait(boolean await) throws Exception { Class<?> paramTypes[] = new Class[1]; paramTypes[0] = Boolean.TYPE; Object paramValues[] = new Object[1]; paramValues[0] = Boolean.valueOf(await); Method method = catalinaDaemon.getClass().getMethod("setAwait", paramTypes); method.invoke(catalinaDaemon, paramValues); } //调用catalina.load方法 private void load(String[] arguments) throws Exception { // Call the load() method String methodName = "load"; Object param[]; Class<?> paramTypes[]; if (arguments==null || arguments.length==0) { paramTypes = null; param = null; } else { paramTypes = new Class[1]; paramTypes[0] = arguments.getClass(); param = new Object[1]; param[0] = arguments; } Method method = catalinaDaemon.getClass().getMethod(methodName, paramTypes); if (log.isDebugEnabled()) log.debug("Calling startup class " + method); method.invoke(catalinaDaemon, param); } //调用catalina.start函数启动Server public void start() throws Exception { if( catalinaDaemon==null ) init(); Method method = catalinaDaemon.getClass().getMethod("start", (Class [] )null); method.invoke(catalinaDaemon, (Object [])null); } //异常处理 private static void handleThrowable(Throwable t) { if (t instanceof ThreadDeath) { throw (ThreadDeath) t; } if (t instanceof VirtualMachineError) { throw (VirtualMachineError) t; } // All other instances of Throwable will be silently swallowed } }
//Catalina
public class Catalina { protected String configFile = "conf/server.xml"; protected Server server = null; public void start() { if (getServer() == null) { //加载Server实例 load(); } long t1 = System.nanoTime(); try { //启动Server getServer().start(); } catch (LifecycleException e) { try { getServer().destroy(); } } long t2 = System.nanoTime(); if(log.isInfoEnabled()) { log.info("Server startup in " + ((t2 - t1) / 1000000) + " ms"); } // Register shutdown hook if (useShutdownHook) { if (shutdownHook == null) { shutdownHook = new CatalinaShutdownHook(); } Runtime.getRuntime().addShutdownHook(shutdownHook); // If JULI is being used, disable JULI's shutdown hook since // shutdown hooks run in parallel and log messages may be lost // if JULI's hook completes before the CatalinaShutdownHook() LogManager logManager = LogManager.getLogManager(); if (logManager instanceof ClassLoaderLogManager) { ((ClassLoaderLogManager) logManager).setUseShutdownHook( false); } } if (await) { await(); stop(); } } //新建一个Server实例 public void load() { initDirs(); // Before digester - it may be needed initNaming(); // Create and execute our Digester Digester digester = createStartDigester(); InputSource inputSource = null; InputStream inputStream = null; File file = null; //加载"conf/server.xml"文件 try { try { file = configFile(); inputStream = new FileInputStream(file); inputSource = new InputSource(file.toURI().toURL().toString()); } } if (inputStream == null) { try { inputStream = getClass().getClassLoader() .getResourceAsStream(getConfigFile()); inputSource = new InputSource (getClass().getClassLoader() .getResource(getConfigFile()).toString()); } } // This should be included in catalina.jar // Alternative: don't bother with xml, just create it manually. if( inputStream==null ) { try { inputStream = getClass().getClassLoader() .getResourceAsStream("server-embed.xml"); inputSource = new InputSource (getClass().getClassLoader() .getResource("server-embed.xml").toString()); } catch (Exception e) { if (log.isDebugEnabled()) { log.debug(sm.getString("catalina.configFail", "server-embed.xml"), e); } } } if (inputStream == null || inputSource == null) { if (file == null) { log.warn(sm.getString("catalina.configFail", getConfigFile() + "] or [server-embed.xml]")); } else { log.warn(sm.getString("catalina.configFail", file.getAbsolutePath())); if (file.exists() && !file.canRead()) { log.warn("Permissions incorrect, read permission is not allowed on the file."); } } return; } try { inputSource.setByteStream(inputStream); digester.push(this); //解析conf/server.xml文件 digester.parse(inputSource); } } getServer().setCatalina(this); // Stream redirection initStreams(); try { //启动Server getServer().init();} } //初始化目录环境 protected void initDirs() { //CATALINA_HOME String catalinaHome = System.getProperty(Globals.CATALINA_HOME_PROP); if (catalinaHome == null) { // Backwards compatibility patch for J2EE RI 1.3 String j2eeHome = System.getProperty("com.sun.enterprise.home"); if (j2eeHome != null) { catalinaHome=System.getProperty("com.sun.enterprise.home"); } else if (System.getProperty(Globals.CATALINA_BASE_PROP) != null) { catalinaHome = System.getProperty(Globals.CATALINA_BASE_PROP); } } // last resort - for minimal/embedded cases. if(catalinaHome==null) { catalinaHome=System.getProperty("user.dir"); } if (catalinaHome != null) { File home = new File(catalinaHome); if (!home.isAbsolute()) { try { catalinaHome = home.getCanonicalPath(); } catch (IOException e) { catalinaHome = home.getAbsolutePath(); } } System.setProperty(Globals.CATALINA_HOME_PROP, catalinaHome); } if (System.getProperty(Globals.CATALINA_BASE_PROP) == null) { System.setProperty(Globals.CATALINA_BASE_PROP, catalinaHome); } else { String catalinaBase = System.getProperty(Globals.CATALINA_BASE_PROP); File base = new File(catalinaBase); if (!base.isAbsolute()) { try { catalinaBase = base.getCanonicalPath(); } catch (IOException e) { catalinaBase = base.getAbsolutePath(); } } System.setProperty(Globals.CATALINA_BASE_PROP, catalinaBase); } String temp = System.getProperty("java.io.tmpdir"); if (temp == null || (!(new File(temp)).exists()) || (!(new File(temp)).isDirectory())) { log.error(sm.getString("embedded.notmp", temp)); } } //初始化Out,Err流 protected void initStreams() { // Replace System.out and System.err with a custom PrintStream System.setOut(new SystemLogHandler(System.out)); System.setErr(new SystemLogHandler(System.err)); } //初始化命名属性 protected void initNaming() { // Setting additional variables if (!useNaming) { log.info( "Catalina naming disabled"); System.setProperty("catalina.useNaming", "false"); } else { System.setProperty("catalina.useNaming", "true"); String value = "org.apache.naming"; String oldValue = System.getProperty(javax.naming.Context.URL_PKG_PREFIXES); if (oldValue != null) { value = value + ":" + oldValue; } System.setProperty(javax.naming.Context.URL_PKG_PREFIXES, value); if( log.isDebugEnabled() ) { log.debug("Setting naming prefix=" + value); } value = System.getProperty (javax.naming.Context.INITIAL_CONTEXT_FACTORY); if (value == null) { System.setProperty (javax.naming.Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory"); } else { log.debug( "INITIAL_CONTEXT_FACTORY already set " + value ); } } } //实际调用的为load() public void load(String args[]) { try { if (arguments(args)) { load(); } } } //根据参数,转化Catalina状态 protected boolean arguments(String args[]) { boolean isConfig = false; if (args.length < 1) { usage(); return (false); } for (int i = 0; i < args.length; i++) { if (isConfig) { configFile = args[i]; isConfig = false; } else if (args[i].equals("-config")) { isConfig = true; } else if (args[i].equals("-nonaming")) { setUseNaming( false ); } else if (args[i].equals("-help")) { usage(); return (false); } else if (args[i].equals("start")) { //设置为运行状态 starting = true; stopping = false; } else if (args[i].equals("configtest")) { starting = true; stopping = false; } else if (args[i].equals("stop")) { starting = false; stopping = true; } else { usage(); return (false); } } return (true); } }
//Digester
public class Digester extends DefaultHandler2 { //解析conf/server.xml文件 public Object parse(InputSource input) throws IOException, SAXException { configure(); getXMLReader().parse(input); return (root); } //设置配置状态 protected void configure() { // Do not configure more than once if (configured) { return; } log = LogFactory.getLog("org.apache.tomcat.util.digester.Digester"); saxLog = LogFactory.getLog("org.apache.tomcat.util.digester.Digester.sax"); //执行懒加载,留给子类扩展 initialize(); //解析,设置配置状态为true configured = true; } //执行懒加载,留给子类扩展 protected void initialize() { } }
总结:
从以上分析,可以得出startup.sh实际,确定catalina.sh的目录,及是否有执行权限,在执行catalina.sh;而Catalina.sh所做的事情实际上是,初始化Catalina,home以及base目录,初始化JVM参数,执行Bootstrap的main(String[]{start))函数,Bootstrap的main函数,也就是tomcat的启动入口。Bootstrap的main(),执行初始化类加载器,设置catalina,home和base目录,设置当前线程的ClassLoader,新建Catalina实例,设置Catalina的父加载器(setParentClassLoader);通过反射获取Catalina的catalina.setAwait方法,设置为等待状态标识(daemon.setAwait(true);),调用catalina.load函数,初始化Server,目录,命名空间等(daemon.load(args);),调用catalina.start函数启动Server。后面Catalina.start()所做的事情(StandardServer,StandardService,
StandardEngin,StandardHost,Wrapper(StandardWrapper),StandardContext,StandardContainer,Connector),我们在后续文章中,再分析。
Tomcat的Server初始化及启动过程:http://donald-draper.iteye.com/admin/blogs/2327060
附:Serve.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" /> <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html --> <Listener className="org.apache.catalina.core.JasperListener" /> <!-- 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 (blocking & non-blocking) Java AJP Connector: /docs/config/ajp.html APR (HTTP/AJP) Connector: /docs/apr.html Define a non-SSL HTTP/1.1 Connector on port 8080 --> <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> <!-- A "Connector" using the shared thread pool--> <!-- <Connector executor="tomcatThreadPool" port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> --> <!-- Define a SSL HTTP/1.1 Connector on port 8443 This connector uses the BIO implementation that requires the JSSE style configuration. When using the APR/native implementation, the OpenSSL style configuration is required as described in the APR/native documentation --> <!-- <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" maxThreads="150" SSLEnabled="true" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" /> --> <!-- Define an AJP 1.3 Connector on port 8009 --> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> <!-- 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="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>
发表评论
-
tomcat日志及log4j日志乱码
2017-04-26 15:00 5500Linux系统字符编码:http://www.cnblogs. ... -
SQL盲注的解决方案
2016-10-27 18:35 2570引起SQL盲注的原因:http://www-01.ibm.co ... -
Tomcat的HTTPS配置详解
2016-10-27 16:59 972HTTPS原理详解:http://blog.csdn.net/ ... -
Tomcat的StandardService,Executor初始化与启动
2016-10-13 09:15 1610Tomcat的Server初始化及启动过程:http://do ... -
Tomcat的JioEndPoint,处理HTTP请求
2016-10-12 19:02 1251Tomcat的Connector(Protocol,Coyot ... -
Tomcat的Connector(Protocol,CoyoteAdapterAdapter,AprEndPoint)初始化及请求处理过程
2016-10-12 16:46 1619Tomcat的Server初始化及启动过程:http://do ... -
Tomcat问题集
2016-10-09 17:50 809tcnative-1.dll: Can't load AMD ... -
Tomcat-ConfigContext监听器(Context.xml,web.xml)
2016-09-27 12:59 1984Tomcat的Host初始化(Context,Listener ... -
Tomcat的Host初始化(Context,Listener,Filter,Servlet)
2016-09-27 08:42 1499Tomcat的Engine初始化,启动过程:http://do ... -
Tomcat的Engine初始化,启动过程
2016-09-26 15:33 2301Tomcat的Server初始化及启动过程:http://do ... -
Tomcat的Server初始化及启动过程
2016-09-26 11:02 2938Tomcat7,启动过程(BootStrap、Catalina ... -
405 request method post not supported
2016-08-18 18:09 32301.检查链接地址有没有错误 2.看RequestMethod, ... -
apache-tomcat-7.0.67\bin\tcnative-1.dll: Can't load AMD 64-bit .dll on a IA 3
2016-08-12 13:02 1125F:\apache-tomcat-7.0.67\bin\tcn ...
相关推荐
Bootstrap是Apache Tomcat服务器的核心启动类,它是Tomcat初始化过程中的关键部分,主要负责加载服务器的配置信息并启动核心服务。在Java应用服务器领域,理解如何通过Bootstrap接口控制Tomcat的启动与关闭对于运维...
总结来说,Tomcat 6的启动过程涉及到Bootstrap类的初始化、Catalina类的加载和配置解析,以及Digester的XML解析功能。这个过程保证了Tomcat能够正确地加载和应用配置,启动并运行Java Web应用程序。理解这一过程对于...
从 `Bootstrap` 类开始,逐步初始化类加载器、加载配置文件,直到启动服务器并监听端口,最终形成一个完整的 Tomcat 启动过程。这一过程不仅揭示了 Tomcat 内部工作原理,也为进一步理解和优化 Tomcat 配置提供了...
【描述】:Tomcat作为Apache软件基金会的开源Java Servlet容器,其启动过程是理解其工作原理的关键部分。Tomcat的启动顺序涉及到多个层次的加载,从Bootstrap类开始,逐步加载系统配置、公共库、共享库以及Web应用...
Tomcat-Bootstrap是Tomcat启动过程中的核心部分,它的主要职责是加载Tomcat的核心类并初始化服务器。这个jar文件包含了用于启动Tomcat服务器的基本Java代码。当我们在命令行中运行`catalina.sh`或`catalina.bat`启动...
1. Bootstrap:启动过程始于Bootstrap类,它加载并初始化Server对象。 2. Server:Server对象包含了全局配置信息,并管理Service组件。 3. Service:Service包含一个或多个Connector(如Coyote)和一个Engine。 4...
- 启动过程从解析位于`<CATALINA_HOME>/bin`目录下的`.bat`或`.sh`文件开始。 - 在Windows环境下,通常使用`startup.bat`脚本来启动Tomcat。 - 脚本内部最终会调用`org.apache.catalina.startup.Bootstrap`类进行...
以下是对Tomcat7启动流程的一个深入分析: 1. **启动脚本**:通过执行`startup.bat`或`startup.sh`(取决于操作系统)来启动Tomcat。这些脚本会调用`catalina.bat`或`catalina.sh`。 2. **加载Classpath**:在启动...
2. **调用`bootstrap.jar`**:通过调用`bootstrap.jar`中的类来启动Tomcat。这部分涉及使用`java`命令执行`bootstrap.jar`。 3. **内存参数配置**:设置JVM的初始堆大小`-Xms`和最大堆大小`-Xmx`。例如:`-Xms128m -...
这种方法适用于那些不希望使用插件或者遇到插件问题的开发者,同时也能让你更深入地了解Tomcat的启动过程。不过,值得注意的是,虽然这种方法可行,但在大型项目或频繁调试的场景下,使用专门的插件(如"Tomcat插件...
在Linux环境下安装Tomcat7的过程中,首先需要确保系统已经安装了Java Development Kit(JDK),因为Tomcat是基于Java的Web服务器和应用服务器,依赖于JDK来运行。下面是详细的步骤: 一、安装JDK 1. **下载JDK**:...
接下来,需要修改Tomcat的启动脚本`catalina.sh`,以便在启动时使用cronolog进行日志文件的切分。 #### 修改`catalina.sh` 1. **找到`catalina.sh`文件的位置**: 通常位于`$TOMCAT_HOME/bin`目录下。 2. **注释...
在IT行业中,尤其是在Java开发和Web服务器管理中,Bootstrap路径问题常常是开发者遇到的一个常见问题。...同时,了解并理解classpath以及服务器启动过程中的依赖关系,对于开发者来说是提升问题解决能力的关键。
service install Tomcat6 --startmode=jvm --stopmode=winstop --DisplayName="Apache Tomcat" --Classpath="%CATALINA_HOME%\bin\bootstrap.jar;%CATALINA_HOME%\bin\tomcat-juli.jar" --JvmMs=256m --JvmMx=512m ...
- **Bootstrap 类**:启动过程始于`Bootstrap`类。这个类主要负责创建Tomcat的主要组件,并初始化系统环境。 - `initClassLoaders()`:初始化类加载器,为后续的组件加载做准备。 - `parse(server.xml)`:解析`...
对于tomcat的启动流程分析,从主流程Bootstrap -> Catalina -> Server -> service -> engine,connector;和分流程1.engine->host->context->wrapper ;2.connector -> ProtocolHandler->Endpoint;之中的方法调用进行...
标签“源码”可能暗示这篇博文深入到Tomcat的源代码层面,讲解了如何理解启动过程中的内部机制。而“工具”可能指的是使用某些辅助工具来管理和监控Tomcat的启动状态。 压缩包中的`test.vbs`和`t.vbs`文件可能是...
在IT领域,Ant和Tomcat是两个非常重要的工具,它们分别用于自动化构建过程和部署Java Web应用程序。在本文中,我们将深入探讨如何使用Ant通过XML配置来启动和关闭Tomcat服务器,这一技能对于任何从事Java Web开发的...
- `catalina.out`是Tomcat默认的日志文件。 - 随着时间的增长,此日志文件可能会变得非常大。 - 大型日志文件可能影响系统性能,并使日志分析变得困难。 2. **影响**: - 性能问题: 大型日志文件可能会占用大量...
3. 启动Java进程:通过`exec`命令启动Java虚拟机,传递`Bootstrap`类和相应的参数,如`start`命令会使用`java org.apache.catalina.startup.Bootstrap start`来启动Tomcat服务。 4. 服务运行:`Bootstrap`类会加载...