tomcat8 maven插件 - 找不到rt.jar

时间:2017-10-20 22:51:20

标签: maven tomcat8 maven-tomcat-plugin

我正在尝试使用我从以下网址下载的maven tomcat8插件:

https://mvnrepository.com/artifact/org.apache.tomcat.maven/tomcat8-maven-plugin

当我使用mvn tomcat8:run时,我收到以下错误:

SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/launchbi-admin]]
        at java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.util.concurrent.FutureTask.get(FutureTask.java:192)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:868)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/launchbi-admin]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
        ... 6 more
Caused by: java.lang.RuntimeException: C:\Program%20Files\Java\jdk1.8.0_151\jre\lib\rt.jar (The system cannot find the path specified)
        at org.apache.tomcat.maven.plugin.tomcat8.run.RunMojo$2.urlToWebResource(RunMojo.java:499)
        at org.apache.tomcat.maven.plugin.tomcat8.run.RunMojo$2.getClassLoaderResource(RunMojo.java:383)
        at org.apache.catalina.loader.WebappClassLoaderBase.findResourceInternal(WebappClassLoaderBase.java:2529)
        at org.apache.catalina.loader.WebappClassLoaderBase.findResource(WebappClassLoaderBase.java:929)
        at org.apache.catalina.loader.WebappClassLoaderBase.getResourceAsStream(WebappClassLoaderBase.java:1096)
        at org.apache.catalina.startup.ContextConfig.populateJavaClassCache(ContextConfig.java:2148)
        at org.apache.catalina.startup.ContextConfig.populateJavaClassCache(ContextConfig.java:2138)
        at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:2043)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:1995)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1944)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1919)
        at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1880)
        at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1149)
        at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:771)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:305)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5120)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 6 more
Caused by: java.io.FileNotFoundException: C:\Program%20Files\Java\jdk1.8.0_151\jre\lib\rt.jar (The system cannot find the path specified)
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:225)
        at java.util.zip.ZipFile.<init>(ZipFile.java:155)
        at java.util.jar.JarFile.<init>(JarFile.java:166)
        at java.util.jar.JarFile.<init>(JarFile.java:103)
        at org.apache.tomcat.maven.plugin.tomcat8.run.RunMojo$2.urlToWebResource(RunMojo.java:479)

但是,rt.jar确实存在且我的JAVA_HOME环境设置正确:

  

mvn -v   Apache Maven 3.3.9(bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T16:41:47 + 00:00)
  Maven主页:C:\ Users \ Jonathan \ Downloads \ apache-maven-3.3.9-bin \ apache-maven-3.3.9
  Java版本:1.8.0_151,供应商:Oracle Corporation
  Java home:C:\ Program Files \ Java \ jdk1.8.0_151 \ jre
  默认语言环境:en_GB,平台编码:Cp1252
  操作系统名称:&#34; windows 10&#34;,版本:&#34; 10.0&#34;,arch:&#34; amd64&#34;,family:&#34; dos&#34;

2 个答案:

答案 0 :(得分:0)

问题是路径C:\Program%20Files\ ...

中的URL编码空格字符

它不是 - afaik - 有效的Windows路径。

如果你没有自己明确设置它可能是插件中的错误。

更新:这似乎是一个错误:

Maven goal of tomcat8:run fails if Java runtime is installed in path containing spaces

答案 1 :(得分:0)

tomcat maven插件支持的最高版本是tomcat 7,你可以试试有几个嵌入式容器的spring boot