gpt4 book ai didi

java - tomcat 启动失败 : SEVERE: Error starting static Resources

转载 作者:行者123 更新时间:2023-11-28 23:39:36 25 4
gpt4 key购买 nike

我已经通读了所有现有的答案,但仍然无法解决我的问题。

  1. 我有一个嵌入式 tomcat 实例,它曾经工作很好
  2. 我什至创建了一个全新的安装,但它仍然在同理
  3. 我重新启动了我的机器;模糊地希望那会帮助。它没。
  4. 我不擅长配置(我正在不过更好……)

我如何启动服务器:

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();
}

最佳答案

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

我通过以下方式发现了这一点:

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

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

关于java - tomcat 启动失败 : SEVERE: Error starting static Resources,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21287440/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com