R01010010
R01010010

Reputation: 5958

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

First of all i don't have a clue about Maven, nor Tomcat, nor Java.

I have a .war file with a webpage and a Tomcat 8 server installed in a Mac (Yosemite). Is located at /Library/Tomcat/webapps/wm-admin-ui.war. I also have Maven (v3) installed and configured with a tomcat user.

I need to run the .war in a Tomcat server that apparently is intended to be deployed by some Maven plugin. I figured this out because there's a maven directory at META-INF and the usual deployment doesn't work at all. See picture below as reference.

Thing is,

Directory structure of '/Library/Tomcat/webapps/wm-admin-ui' :

enter image description here

The errors at the catalina.out log:

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)

This is the code that throughs the error:

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

Upvotes: 0

Views: 2253

Answers (1)

Paweł Głowacz
Paweł Głowacz

Reputation: 3046

It seems that class com.toro.wm.configurations.WmWebApplicationInitializer with method getSwaggerBasePath has problem with load some property file.

Check this line in this class WmWebApplicationInitializer.java:86. Seems you haven't deployed crucial file and when application initialize context it demands that file.

Second problem is you need to put all properties in path WEB-INF/classes.

Now all should work.

Upvotes: 1

Related Questions