运行(部署?)a" maven" .war在TOMCAT 8

时间:2015-08-11 09:01:00

标签: maven tomcat tomcat8 maven-tomcat-plugin

首先,我不知道Maven,Tomcat和Java。

我有一个.war文件,其中包含一个网页和一台安装在Mac(Yosemite)中的Tomcat 8服务器。位于/Library/Tomcat/webapps/wm-admin-ui.war。 我还安装了Maven(v3)并配置了tomcat用户。

我需要在Tomcat服务器中运行.war,它显然是由一些Maven插件部署的。我认为这是因为在META-INF上有一个maven目录,而且通常的部署根本不起作用。见下面的图片作为参考。

事情是,

  • 如何在tomcat 8中安装maven插件? (我已经检查了谷歌)
  • 是"部署" "运行"?
  • 的同义词

' / Library / Tomcat / webapps / wm-admin-ui'的目录结构:

enter image description here

catalina.out日志中的错误:

11-Aug-2015 10:23:43.128 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars Al menos un JAR, que se ha explorado buscando TLDs, aún no contenía TLDs. Activar historial de depuración para este historiador para una completa lista de los JARs que fueron explorados y de los que nos se halló TLDs. Saltarse JARs no necesarios durante la exploración puede dar lugar a una mejora de tiempo significativa en el arranque y compilación de JSP .
11-Aug-2015 10:23:43.360 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: 
 org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/wm-admin-ui]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1768)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
    at java.util.Properties$LineReader.readLine(Properties.java:434)
    at java.util.Properties.load0(Properties.java:353)
    at java.util.Properties.load(Properties.java:341)
    at com.toro.wm.configurations.WmWebApplicationInitializer.getSwaggerBasePath(WmWebApplicationInitializer.java:86)
    at com.toro.wm.configurations.WmWebApplicationInitializer.onStartup(WmWebApplicationInitializer.java:70)
    at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5156)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 10 more

11-Aug-2015 10:23:43.362 SEVERE [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Error durante el despliegue del archivo /Users/r01010010/Develop/apache-tomcat-8.0.24/webapps/wm-admin-ui.war de la aplicación web
 java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/wm-admin-ui]]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:729)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1768)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

这是通过错误的代码:

private String getSwaggerBasePath() {
    InputStream is = getClass().getResourceAsStream("/swagger.properties");
    Properties properties = new Properties();
    try {
        properties.load(is);
        is.close();
    } catch (IOException e) {
        LOGGER.error("Failed to handle stream for swagger.properties file ", e);
    }

    String context = properties.getProperty("swagger.base_path", "");

    return (StringUtils.isEmpty(context) ? "" : context) + "/wm-admin-ui/rest";
}

1 个答案:

答案 0 :(得分:1)

似乎带有方法com.toro.wm.configurations.WmWebApplicationInitializer的类getSwaggerBasePath在加载某些属性文件时出现问题。

在此课程WmWebApplicationInitializer.java:86中查看此行。似乎你没有部署关键文件,当应用程序初始化上下文时,它需要该文件。

第二个问题是您需要将所有属性放在路径WEB-INF/classes中。

现在一切都应该有效。