tomcat无法启动:SEVERE:启动静态资源时出错

时间:2014-01-22 15:44:32

标签: java tomcat

我一直在阅读所有现有的答案,仍然无法解决我的问题。

  1. 我有一个嵌入式tomcat实例,它用来工作很好
  2. 我甚至创建了一个全新的安装,它仍然在中断 同样的方式
  3. 我重新启动了我的机器;在模糊的希望,那会 救命。它没。
  4. 我不擅长配置(我得到了 更好,但....)
  5. 我如何启动服务器:

    alias run-server='cd /Users/usingji/Code/sandbox/gcs/target/GlobalContentDelivery-Package/GlobalContentDelivery/; java -Dgcs.log.dir=/Users/usingji/mediaServer/log -Dgcs.home.dir=/Users/usingji/Code/sandbox/gcs/target/GlobalContentDelivery-Package/GlobalContentDelivery -jar GCS-v0.9.jar'
    

    我的错误:

       0:36:45,083 INFO  [PropertyUtil] Loading Property file
    10:36:45,084 INFO  [PropertyUtil] Loading Property file
    10:36:45,085 INFO  [ServerLauncher] webPort is 8080
    10:36:45,085 INFO  [ServerLauncher] web root is webapp 
    10:36:45,091 INFO  [ServerLauncher] base path: /Users/usingji/Code/sandbox/gcs/target/GlobalContentDelivery-Package/GlobalContentDelivery
    10:36:45,092 INFO  [ServerLauncher] just set the port
    10:36:45,092 INFO  [ServerLauncher] config name: webapp 
    10:36:45,092 INFO  [ServerLauncher] file: ackack: /Users/usingji/Code/sandbox/gcs/target/GlobalContentDelivery-Package/GlobalContentDelivery/webapp 
    10:36:45,092 INFO  [ServerLauncher] absolute path: /Users/usingji/Code/sandbox/gcs/target/GlobalContentDelivery-Package/GlobalContentDelivery/webapp 
    10:36:45,175 INFO  [ServerLauncher] configuring app with basedir: /Users/usingji/Code/sandbox/gcs/target/GlobalContentDelivery-Package/GlobalContentDelivery/webapp 
    Jan 22, 2014 10:36:45 AM org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler ["http-bio-8080"]
    Jan 22, 2014 10:36:45 AM org.apache.catalina.core.StandardService startInternal
    INFO: Starting service Tomcat
    Jan 22, 2014 10:36:45 AM org.apache.catalina.core.StandardEngine startInternal
    INFO: Starting Servlet Engine: Apache Tomcat/7.0.34
    Jan 22, 2014 10:36:45 AM org.apache.catalina.startup.ContextConfig getDefaultWebXmlFragment
    INFO: No global web.xml found
    Jan 22, 2014 10:36:46 AM org.apache.catalina.core.StandardContext resourcesStart
    SEVERE: Error starting static Resources
    java.lang.IllegalArgumentException: Document base /Users/usingji/Code/sandbox/gcs/target/GlobalContentDelivery-Package/GlobalContentDelivery/webapp  does not exist or is not a readable directory
        at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:138)
        at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4906)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5086)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:724)
    
    Jan 22, 2014 10:36:46 AM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Error in resourceStart()
    Jan 22, 2014 10:36:46 AM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Error getConfigured
    Jan 22, 2014 10:36:46 AM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Context [/] startup failed due to previous errors
    Jan 22, 2014 10:36:46 AM org.apache.coyote.AbstractProtocol start
    INFO: Starting ProtocolHandler ["http-bio-8080"]
    10:36:46,227 INFO  [ServerLauncher] Starting Tomcast ...
    

    webapp目录确实存在:

    drwxr-xr-x   6 usingji  PEROOT\Domain Users    204 Jan 22 10:34 webapp
    

    启动tomcat实例的代码:

     public static void main(String[] args) throws Exception {
    
            // load all the default configs files
            loadDefaults();
    
            // // port number
            String webPort;
            webPort = System.getProperty("gcs.web.port");
            if (webPort == null) {
                webPort = System.getenv("gcs.web.port");
            }
            if (webPort == null) {
                webPort = PropertyUtil.getValue(Constants.PORT_CONFIG_NAME);
            }
            log.info("webPort is " + webPort);
            String webappDirLocation = PropertyUtil.getValue(Constants.WEBAPP_CONFIG_NAME);
            log.info("web root is " + webappDirLocation);
            tomcat = new Tomcat();
            String basePath = FileUtil.getBasePath();
            log.info("base path: " + basePath);
            tomcat.setBaseDir(basePath);
            tomcat.setPort(Integer.valueOf(webPort));
            log.info("just set the port");
    
            String configName= PropertyUtil.getValue(Constants.WEBAPP_CONFIG_NAME);
            log.info("config name: "+ configName);
            File ackack = new File(basePath,configName);
            log.info("file: ackack: " + ackack);
           String absPath  = ackack.getAbsolutePath();
           log.info("absolute path: " + absPath);
            StandardContext ctx = (StandardContext) tomcat.addWebapp(
                    "/",
                    absPath);
            ctx.setDefaultWebXml(new File(webappDirLocation).getAbsolutePath()
                    + "/WEB-INF/web.xml");
    
            // unzip folder location
            tomcat.addWebapp(PropertyUtil.getValue(Constants.EXPORT_URL_PATH),
                    PropertyUtil.getValue(Constants.PXE_UNZIP_FOLDER));
    
            log.info("configuring app with basedir: "
                    + new File(webappDirLocation).getAbsolutePath());
    
            tomcat.start();
            log.info("Starting Tomcast ...");
            tomcat.getServer().await();
        }
    

1 个答案:

答案 0 :(得分:0)

事实证明,具有文件夹链接的配置文件(webapp)在文件名后面有空格或不可见的控制字符。

我发现了这个:

  1. 恢复到有效代码的早期版本
  2. 我的同事     提到他们有同样的问题和修复配置     文件修复了它
  3. 然后我将非工作配置文件与工作文件区分开来并发现了问题

如此令人沮丧和阴险!我很高兴现在已经解决了!