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

Run (deploy?) a "maven" .war in TOMCAT 8

首先,我对 Maven、Tomcat、Java 都一无所知。

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

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

事实是,

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

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";
}

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

检查此 class WmWebApplicationInitializer.java:86 中的这一行。似乎您还没有部署关键文件,当应用程序初始化上下文时它需要该文件。

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

现在一切正常。