zoukankan      html  css  js  c++  java
  • 当有两个不同名称,但是内容一样的项目,在tomcat中启动的问题解决

    SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.util.Log4jConfigListener
    java.lang.IllegalStateException: Web app root system property already set to different value: 'webapp.root' = [/usr/apache-tomcat-6.0.35/webapps/wms/] instead of [/usr/apache-tomcat-6.0.35/webapps/wmsFDC/] - Choose unique values for the 'webAppRootKey' context-param in your web.xml files!
     at org.springframework.web.util.WebUtils.setWebAppRootSystemProperty(WebUtils.java:147)
     at org.springframework.web.util.Log4jWebConfigurer.initLogging(Log4jWebConfigurer.java:117)
     at org.springframework.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:45)
     at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
     at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
     at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
     at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
     at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
     at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
     at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
     at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
     at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
     at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
     at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
     at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
     at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
     at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
     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:754)
     at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
     at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

     看看异常,还是挺简单的,应该是两个项目的设置重复了,导致出错,但我发现web.xml里并没有配置webAppRootKey项
     原来是因为如果没有web.xm 内没有设置webAppRootKey项,是为默认设置

    public  static  void  setWebAppRootSystemProperty(ServletContext servletContext) throws  IllegalStateException  {
           String  param = servletContext.getInitParameter(WEB_APP_ROOT_KEY_PARAM);
           String  key = (param != null  ? param : DEFAULT_WEB_APP_ROOT_KEY); 
           String  oldValue = System .getProperty(key); 
           if  (oldValue != null ) { 
               throw  new  IllegalStateException ("WARNING: Web app root system property already set: "  + key + " = "  + 
                oldValue + " - Choose unique webAppRootKey values in your web.xml files!" );
             } 
            String  root = servletContext.getRealPath("/" ); 
            if  (root == null ) { 
                throw  new  IllegalStateException ("Cannot set web app root system property when WAR file is not  expanded");
             } 
           System .setProperty(key, root); 
           servletContext.log("Set web app root system property: "  + key + " = "  + root);
         } 
    在web.xml中加入
    ### app1:
    <context-param>
        <param-name>webAppRootKey</param-name>
        <param-value>app1.root</param-value>
    </context-param>

    ### app2:
    <context-param>
        <param-name>webAppRootKey</param-name>
        <param-value>app2.root</param-value>
    </context-param>

  • 相关阅读:
    iOS版打地鼠游戏源码
    OuNews 简单的新闻客户端应用源码
    安卓DJ113舞曲网应用客户端 项目源码(服务器+客户端)
    博客迁移
    iOS 多张图片保存到相册问题(add multiple images to photo album)
    【转】 iOS 学习之 NSPredicate 模糊、精确、查询
    iOS 设置图片imageView圆角——对图片进行裁剪
    iOS9的那些坑 — — WeiboSDK registerApp启动就崩溃
    关于Debug下的Log打印问题
    Runtime运行时学习(一)
  • 原文地址:https://www.cnblogs.com/liuwenjun/p/3399327.html
Copyright © 2011-2022 走看看