• log4j加载方式导致的bae和sae部署异常


    这2天改在bae上部署代码,为了便于程序的功能测试,引入了log4j日志,但是问题来了..测试程序采用的是spring3.2.8框架搭建,web.xml引入日志代码为:

     <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>classpath:log4j.xml</param-value>
      </context-param>
      <!-- 
          <context-param>
            <param-name>webAppRootKey</param-name>
            <param-value>app.root</param-value>
        </context-param>
       -->
      <listener>
        <listener-class>
            org.springframework.web.util.Log4jConfigListener
        </listener-class>
      </listener>

    部署失败,报错为:

    2015-02-12 17:43:06,878 [localhost-startStop-4] INFO org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]- Shutting down log4j
    2015-02-12 17:43:06,877 [localhost-startStop-4] ERROR org.apache.catalina.core.StandardContext- Context [] startup failed due to previous errors
    2015-02-12 17:43:06,877 [localhost-startStop-4] ERROR org.apache.catalina.core.StandardContext- Error listenerStart
    at java.lang.Thread.run(Thread.java:724)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1660)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:983)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
    at org.springframework.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:45)
    at org.springframework.web.util.Log4jWebConfigurer.initLogging(Log4jWebConfigurer.java:116)
    at org.springframework.web.util.WebUtils.setWebAppRootSystemProperty(WebUtils.java:143)
    java.lang.IllegalStateException: Cannot set web app root system property when WAR file is not expanded
    2015-02-12 17:43:06,875 [localhost-startStop-4] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]- Exception sending context initialized event to listener instance of class org.springframework.web.util.Log4jConfigListener
    2015-02-12 17:43:06,866 [localhost-startStop-4] INFO org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]- No Spring WebApplicationInitializer types detected on classpath
    2015-02-12 17:43:02,593 [localhost-startStop-4] INFO org.apache.catalina.startup.HostConfig- Deploying web application archive /home/bae/app/ROOT.war

    因为本地环境我无法复现,只能猜测是war打包的方式在云端部署与log4j的加载方式有冲突..

    最后无奈,只好耍下赖..web.xml中不写log4j的引入代码,然后把log4j.xml配置文件扔到默认位置src下,让spring自动加载...至此代码成功部署到bae上...

    至于为何标题提到了sae,因为我是被这个问题坑了,在sae上也部署不上,无奈转到bae上,结果bae上也是一样,才意识到问题的非偶然性...

  • 相关阅读:
    java Concurrent包学习笔记(二):CountDownLatch和CyclicBarrier
    java Concurrent包学习笔记(四):BlockingQueue
    Linux Linux程序练习十五(进程间的通信共享内存版)
    Linux shell中的符号
    Linux shell程序一
    Linux Linux程序练习十四(多进程压力测试)
    Linux Linux程序练习十三(信号阻塞,捕获)
    Linux 网络编程详解二(socket创建流程、多进程版)
    Linux 网络编程详解一(IP套接字结构体、网络字节序,地址转换函数)
    Linux shell实战(ipcs工具)
  • 原文地址:https://www.cnblogs.com/chyu/p/4288726.html
Copyright © 2020-2023  润新知