package
org.Apache.catalina.startup;

在Tomcat安插的时候现身Could not resolve placeholder
四月 08, 2015 5:24:09 下午 org.apache.catalina.core.AprLifecycleListener
init
信息: The APR based Apache Tomcat Native library which allows optimal
performance in production environments was not found on the
java.library.path: C:\Program
Files\Java\jre1.8.0_31\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program
Files/Java/jre1.8.0_40/bin/server;C:/Program
Files/Java/jre1.8.0_40/bin;C:/Program
Files/Java/jre1.8.0_40/lib/amd64;D:\app\Administrator\product\11.2.0\client_2\bin;D:\app\Administrator\product\11.2.0\client_1\bin;D:\app\Administrator\product\11.2.0\dbhome_1\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
Files\Apache\apache-maven-3.2.5\bin;C:\Program Files\MySQL\MySQL
Server 5.5\bin;C:\Program Files\Java\jre1.8.0_31\bin;C:\Program
Files\TortoiseSVN\bin;C:\Program Files\eclipse;;.
四月 08, 2015 5:24:09 下午
org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting
property ‘source’ to ‘org.eclipse.jst.j2ee.server:pkp-deliver-web’ did
not find a matching property.
四月 08, 2015 5:24:09 下午 org.apache.coyote.http11.Http11Protocol
init
信息: Initializing Coyote HTTP/1.1 on http-8080
四月 08, 2015 5:24:09 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 347 ms
四月 08, 2015 5:24:09 下午 org.apache.catalina.core.StandardService
start
信息: Starting service Catalina
四月 08, 2015 5:24:09 下午 org.apache.catalina.core.StandardEngine
start
信息: Starting Servlet Engine: Apache Tomcat/6.0.43
四月 08, 2015 5:24:10 下午 org.apache.catalina.core.ApplicationContext
log
信息: Initializing Spring root WebApplicationContext
[08/04/15 05:24:10:010 CST] INFO context.ContextLoader: Root
WebApplicationContext: initialization started
[08/04/15 05:24:10:010 CST] INFO support.XmlWebApplicationContext:
Refreshing Root WebApplicationContext: startup date [Wed Apr 08
17:24:10 CST 2015]; root of context hierarchy
[08/04/15 05:24:10:010 CST] INFO xml.XmlBeanDefinitionReader: Loading
XML bean definitions from URL
[jar:file:/C:/Users/Administrator/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/pkp-deliver-web/WEB-INF/lib/framework-server-1.1.2.jar!/com/deppon/foss/framework/server/META-INF/spring.xml]
[08/04/15 05:24:10:010 CST] INFO xml.XmlBeanDefinitionReader: Loading
XML bean definitions from URL
[jar:file:/C:/Users/Administrator/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/pkp-deliver-web/WEB-INF/lib/pda-bdm-push-0.0.1-express-SNAPSHOT.jar!/com/deppon/pda/bdm/module/push/server/META-INF/spring.xml]
[08/04/15 05:24:10:010 CST] INFO xml.XmlBeanDefinitionReader: Loading
XML bean definitions from ServletContext resource
[/WEB-INF/spring.xml]
[08/04/15 05:24:11:011 CST] INFO support.DefaultListableBeanFactory:
Destroying singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@fd8294b:
defining beans
[org.springframework.aop.config.internalAutoProxyCreator,pushDao,pushService,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,{];
root of factory hierarchy
[08/04/15 05:24:11:011 CST] ERROR context.ContextLoader: Context
initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid
bean definition with name ‘mongo’ defined in ServletContext resource
[/WEB-INF/spring.xml]: Could not resolve placeholder ‘mongodb.host’
at
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:287)
at
org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75)
at
org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:663)
at
org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:638)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:407)
at
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4709)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at
org.apache.catalina.core.StandardService.start(StandardService.java:525)
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:759)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
四月 08, 2015 5:24:11 下午 org.apache.catalina.core.StandardContext
listenerStart
严重: Exception sending context initialized event to listener instance
of class com.deppon.foss.framework.server.web.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid
bean definition with name ‘mongo’ defined in ServletContext resource
[/WEB-INF/spring.xml]: Could not resolve placeholder ‘mongodb.host’
at
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:287)
at
org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75)
at
org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:663)
at
org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:638)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:407)
at
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4709)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at
org.apache.catalina.core.StandardService.start(StandardService.java:525)
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:759)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

src
file:

四月 08, 2015 5:24:11 下午 org.apache.catalina.core.StandardContext
start
严重: Error listenerStart
四月 08, 2015 5:24:11 下午 org.apache.catalina.core.StandardContext
start
严重: Context [/pkp-deliver-web] startup failed due to previous
errors
四月 08, 2015 5:24:11 下午 org.apache.catalina.core.ApplicationContext
log
信息: Closing Spring root WebApplicationContext
四月 08, 2015 5:24:11 下午 org.apache.coyote.http11.Http11Protocol
start
信息: Starting Coyote HTTP/1.1 on http-8080
四月 08, 2015 5:24:11 下午 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
四月 08, 2015 5:24:11 下午 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/18 config=null
四月 08, 2015 5:24:11 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 2212 ms
好纠结,怎么消除啊?那是一个二回开拓的类别……

goal:掌握tomcat运维的大概流程

迎接各位指正当中的谬误和不足

入口main方法

 1 public static void main(String args[]) {   2    3         if (daemon == null) {   4             daemon = new Bootstrap();   5             try {   6                 daemon.init();//init(完成了加载环境变量和类加载器的工作)   7             } catch (Throwable t) {   8                 t.printStackTrace();   9                 return;  10             }  11         }  12   13         try {  14             String command = "start";  15             if (args.length > 0) {  16                 command = args[args.length - 1];  17             }  18   19             if (command.equals("startd")) {  20                 args[args.length - 1] = "start";  21                 daemon.load(args);  22                 daemon.start();  23             } else if (command.equals("stopd")) {  24                 args[args.length - 1] = "stop";  25                 daemon.stop();  26             } else if (command.equals("start")) {// 默认没有参数会进入这里  27                 // 设置挂起标志  28                 daemon.setAwait(true);  29                 // 信息: Initialization processed in 3024454 ms  30                 daemon.load(args);  31                 // 启动server  32                 daemon.start();  33             } else if (command.equals("stop")) {  34                 daemon.stopServer(args);  35             } else {  36                 log.warn("Bootstrap: command \"" + command + "\" does not exist.");  37             }  38         } catch (Throwable t) {  39             t.printStackTrace();  40         }  41   42     }

以上是bootstrap类的main方法,里边稳步调用了一部分用来开首化的方法.上边一1解读:

init()方法:

永利开户送38元体验金 1永利开户送38元体验金 2

 1 /**   2      * Initialize daemon.   3      */   4     public void init() throws Exception {   5    6         // Set Catalina path   7         setCatalinaHome();// 加载Catalina.Home环境变量(catalina.home)   8         setCatalinaBase();// 加载Catalina.Base环境变量(catalina.base)   9   10         initClassLoaders();// 初始化类加载器  11   12         Thread.currentThread().setContextClassLoader(catalinaLoader);  13   14         SecurityClassLoad.securityClassLoad(catalinaLoader);  15   16         // Load our startup class and call its process() method  17         if (log.isDebugEnabled()) {  18             log.debug("Loading startup class");  19         }  20         Class startupClass = catalinaLoader.loadClass("org.apache.catalina.startup.Catalina");  21         Object startupInstance = startupClass.newInstance();  22   23         // Set the shared extensions class loader  24         if (log.isDebugEnabled()) {  25             log.debug("Setting startup class properties");  26         }  27         String methodName = "setParentClassLoader";  28         Class paramTypes[] = new Class[1];  29         paramTypes[0] = Class.forName("java.lang.ClassLoader");  30         Object paramValues[] = new Object[1];  31         paramValues[0] = sharedLoader;  32         // 找到org.apache.catalina.startup.Catalina#setParentClassLoader方法  33         Method method = startupInstance.getClass().getMethod(methodName, paramTypes);  34         // 设置java.lang.ClassLoader为父类加载器  35         method.invoke(startupInstance, paramValues);  36   37         catalinaDaemon = startupInstance;// 设置Catalina进程  38     }

init()方法

  1. 对景况变量的读取,首尽管读取  catalina.home\catalina.base
  2. 开端化类加载器,暗许使用当前类的类加载器  this.getClass().getClassLoader();
  3. 加载了Catalina类  classLoader.loadClass(“org.apache.catalina.startup.Catalina”)
  4. 反射设置父类加载器  org.apache.catalina.startup.Catalina#setParentClassLoader设置java.lang.ClassLoader为ParentClassLoader

永利开户送38元体验金,daemon.setAwait(true)方法:

永利开户送38元体验金 3永利开户送38元体验金 4

 1 /**   2      * Set flag.   3      */   4     public void setAwait(boolean await) throws Exception {   5    6         Class paramTypes[] = new Class[1];   7         paramTypes[0] = Boolean.TYPE;   8         Object paramValues[] = new Object[1];   9         paramValues[0] = new Boolean(await);  10         // 获取Catalina类(其实是其父类Embedded)中的setAwait方法  11         Method method = catalinaDaemon.getClass().getMethod("setAwait", paramTypes);  12         // 使用await参数调用  13         method.invoke(catalinaDaemon, paramValues);  14   15     }

setAwait方法

  1. 本条方式并不曾切实可行的中肯钻研,不过从字面意义上来看,应该是设置了一个锁.迎接各位指正.

daemon.load(args)方法:

永利开户送38元体验金 5永利开户送38元体验金 6

 1 /**   2      * Load daemon.   3      */   4     private void load(String[] arguments) throws Exception {   5    6         // Call the load() method   7         String methodName = "load";   8         Object param[];   9         Class paramTypes[];  10         if (arguments==null || arguments.length==0) {  11             paramTypes = null;  12             param = null;  13         } else {  14             paramTypes = new Class[1];  15             paramTypes[0] = arguments.getClass();  16             param = new Object[1];  17             param[0] = arguments;  18         }  19         // 获取Catalina的load方法  20         Method method = catalinaDaemon.getClass().getMethod(methodName, paramTypes);  21         if (log.isDebugEnabled())  22             log.debug("Calling startup class " + method);  23         // 调用(启动一个新的服务器实例)  24         method.invoke(catalinaDaemon, param);  25   26     }

daemon.load方法

  通过反射调用Catalina的load方法

永利开户送38元体验金 7永利开户送38元体验金 8

 1 /**   2      * Start a new server instance.   3      */   4     public void load() {   5    6         long t1 = System.nanoTime();   7    8         initDirs();// 读取环境变量   9   10         // Before digester - it may be needed  11   12         initNaming();  13   14         // Create and execute our Digester  15         Digester digester = createStartDigester();  16   17         InputSource inputSource = null;  18         InputStream inputStream = null;  19         File file = null;  20         try {  21             file = configFile();//获取server.xml位置  22             inputStream = new FileInputStream(file);  23             inputSource = new InputSource("file://" + file.getAbsolutePath());  24         } catch (Exception e) {  25             ;  26         }  27         // 如果不能获取server.xml,则使用ClassLoader再查找一次  28         if (inputStream == null) {  29             try {  30                 inputStream = getClass().getClassLoader().getResourceAsStream(getConfigFile());  31                 inputSource = new InputSource(getClass().getClassLoader().getResource(getConfigFile()).toString());  32             } catch (Exception e) {  33                 ;  34             }  35         }  36   37         // This should be included in catalina.jar  38         // Alternative: don't bother with xml, just create it manually.  39         if( inputStream==null ) {  40             try {  41                 inputStream = getClass().getClassLoader()  42                 .getResourceAsStream("server-embed.xml");  43                 inputSource = new InputSource  44                 (getClass().getClassLoader()  45                         .getResource("server-embed.xml").toString());  46             } catch (Exception e) {  47                 ;  48             }  49         }  50           51   52         if ((inputStream == null) && (file != null)) {  53             log.warn("Can't load server.xml from " + file.getAbsolutePath());  54             if (file.exists() && !file.canRead()) {  55                 log.warn("Permissions incorrect, read permission is not allowed on the file.");  56             }  57             return;  58         }  59   60         try {  61             inputSource.setByteStream(inputStream);  62             digester.push(this);  63             digester.parse(inputSource);// 加载server.xml  64             inputStream.close();  65         } catch (Exception e) {  66             log.warn("Catalina.start using "  67                                + getConfigFile() + ": " , e);  68             return;  69         }  70   71         // Stream redirection  72         initStreams();// 设置log  73   74         // Start the new server  75         if (getServer() instanceof Lifecycle) {  76             try {  77                 getServer().initialize();  78             } catch (LifecycleException e) {  79                 if (Boolean.getBoolean("org.apache.catalina.startup.EXIT_ON_INIT_FAILURE"))  80                     throw new java.lang.Error(e);  81                 else     82                     log.error("Catalina.start", e);  83                   84             }  85         }  86   87         long t2 = System.nanoTime();  88         if(log.isInfoEnabled())  89             log.info("Initialization processed in " + ((t2 - t1) / 1000000) + " ms");  90   91     }

Catalina.load方法

  1. #initDirs()实现了读取意况变量
  2. #initNaming()设置命名空间catalina.useNaming\java.naming.factory.url.pkgs\java.naming.factory.initial  这多少个命名空间未有切实可行切磋意义,同样接待补充
  3. 创建Digester
  4. 读取server.xml文件
  5. #digester.push(this)
  6. #digester.parse(inputSource)使用digester分析server.xml并根据安插创设Server对象
  7. #initStreams()设置log
  8. 调用#getServer().initialize()启动server

daemon.start()方法:

永利开户送38元体验金 9永利开户送38元体验金 10

 1     /**   2      * Start the Catalina daemon.   3      */   4     public void start() throws Exception {   5         if (catalinaDaemon == null)   6             init();   7    8         Method method = catalinaDaemon.getClass().getMethod("start", (Class[]) null);   9         method.invoke(catalinaDaemon, (Object[]) null);  10   11     }

daemon.start方法

 

  通过反射调用Catalina的start方法

永利开户送38元体验金 11永利开户送38元体验金 12

 1 /**   2      * Start a new server instance.   3      */   4     public void start() {   5    6         if (getServer() == null) {   7             load();   8         }   9   10         if (getServer() == null) {  11             log.fatal("Cannot start server. Server instance is not configured.");  12             return;  13         }  14   15         long t1 = System.nanoTime();  16           17         // Start the new server  18         if (getServer() instanceof Lifecycle) {  19             try {  20                 ((Lifecycle) getServer()).start();  21             } catch (LifecycleException e) {  22                 log.error("Catalina.start: ", e);  23             }  24         }  25   26         long t2 = System.nanoTime();  27         if(log.isInfoEnabled())  28             log.info("Server startup in " + ((t2 - t1) / 1000000) + " ms");  29   30         try {  31             // Register shutdown hook  32             if (useShutdownHook) {  33                 if (shutdownHook == null) {  34                     shutdownHook = new CatalinaShutdownHook();  35                 }  36                 Runtime.getRuntime().addShutdownHook(shutdownHook);  37                   38                 // If JULI is being used, disable JULI's shutdown hook since  39                 // shutdown hooks run in parallel and log messages may be lost  40                 // if JULI's hook completes before the CatalinaShutdownHook()  41                 LogManager logManager = LogManager.getLogManager();  42                 if (logManager instanceof ClassLoaderLogManager) {  43                     ((ClassLoaderLogManager) logManager).setUseShutdownHook(  44                             false);  45                 }  46             }  47         } catch (Throwable t) {  48             // This will fail on JDK 1.2. Ignoring, as Tomcat can run  49             // fine without the shutdown hook.  50         }  51   52         if (await) {  53             await();  54             stop();  55         }  56   57     }

Catalina.start方法

  1. 日趋运营server的生命周期

相关文章