How to deploy a war and an application on Openshift
<p>I am following <a href="https://blog.openshift.com/build-your-own-google-maps-and-more-with-geoserver-on-openshift/" rel="nofollow" title="this">this</a> tutorial to install Geoserver on an Openshift application. The problem is that for the Geoserver (a .war) to run, I have to delete the src folder and the pom.xml from the application, but I need to develop an application there too.</p>

<p>So, how can I mantain the pom.xml and the src folder while having the WAR running (I really need to delete those things in order to get the war running)? Is it even possible?</p>

<p>With src folder and pom.xml I receive this response from Openshift:</p>

<pre><code>remote: [INFO] ----------    --------------------------------------------------------------
remote: [INFO] Building test 1.0
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO]
remote: [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ test ---
remote: [INFO]
remote: [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ test ---
remote: [debug] execute contextualize
remote: [INFO] Using 'UTF-8' encoding to copy filtered resources.
remote: [INFO] Copying 1 resource
remote: [INFO]
remote: [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ test ---
remote: [INFO] Nothing to compile - all classes are up to date
remote: [INFO]
remote: [INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ test ---
remote: [debug] execute contextualize
remote: [INFO] Using 'UTF-8' encoding to copy filtered resources.
remote: [INFO] skip non existing resourceDirectory /var/lib/openshift/56f18c457628e1639500003d/app-root/runtime/repo/src/test/resources
remote: [INFO]
remote: [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ test ---
remote: [INFO] No sources to compile
remote: [INFO]
remote: [INFO] --- maven-surefire-plugin:2.10:test (default-test) @ test ---
remote: [INFO] Tests are skipped.
remote: [INFO]
remote: [INFO] --- maven-war-plugin:2.1.1:war (default-war) @ test ---
remote: [INFO] Packaging webapp
remote: [INFO] Assembling webapp [test] in [/var/lib/openshift/56f18c457628e1639500003d/app-root/runtime/repo/target/test]
remote: [INFO] Processing war project
remote: [INFO] Copying webapp resources [/var/lib/openshift/56f18c457628e1639500003d/app-root/runtime/repo/src/main/webapp]
remote: [INFO] Webapp assembled in [93 msecs]
remote: [INFO] Building war: /var/lib/openshift/56f18c457628e1639500003d/app-root/runtime/repo/webapps/ROOT.war
remote: [INFO] WEB-INF/web.xml already added, skipping
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] BUILD SUCCESS
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] Total time: 4.278s
remote: [INFO] Finished at: Tue Mar 22 14:31:40 EDT 2016
remote: [INFO] Final Memory: 8M/111M
remote: [INFO] ------------------------------------------------------------------------
remote: Preparing build for deployment
remote: Deployment id is a3cec3f4
remote: Activating deployment
remote: Starting Postgres cartridge
remote: Postgres started
remote: Emptying tmp dir: /var/lib/openshift/56f18c457628e1639500003d/jbossews//tmp/Geotools
remote: Starting jbossews cartridge
remote: Found 127.3.185.129:8080 listening port
remote: -------------------------
remote: Git Post-Receive Result: success
remote: Activation status: success
remote: Deployment completed with status: success
</code></pre>

<p>My pom.xml is the default pom.xml that Openshift supplies:</p>

<pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;test&lt;/groupId&gt;
    &lt;artifactId&gt;test&lt;/artifactId&gt;
    &lt;packaging&gt;war&lt;/packaging&gt;
    &lt;version&gt;1.0&lt;/version&gt;
    &lt;name&gt;test&lt;/name&gt;
    &lt;repositories&gt;
        &lt;repository&gt;
            &lt;id&gt;eap&lt;/id&gt;
            &lt;url&gt;http://maven.repository.redhat.com/techpreview/all&lt;/url&gt;
            &lt;releases&gt;
                &lt;enabled&gt;true&lt;/enabled&gt;
            &lt;/releases&gt;
            &lt;snapshots&gt;
                &lt;enabled&gt;true&lt;/enabled&gt;
            &lt;/snapshots&gt;
        &lt;/repository&gt;
    &lt;/repositories&gt;
    &lt;pluginRepositories&gt;
        &lt;pluginRepository&gt;
            &lt;id&gt;eap&lt;/id&gt;
            &lt;url&gt;http://maven.repository.redhat.com/techpreview/all&lt;/url&gt;
            &lt;releases&gt;
                &lt;enabled&gt;true&lt;/enabled&gt;
            &lt;/releases&gt;
            &lt;snapshots&gt;
                &lt;enabled&gt;true&lt;/enabled&gt;
            &lt;/snapshots&gt;
        &lt;/pluginRepository&gt;
    &lt;/pluginRepositories&gt;
    &lt;properties&gt;
        &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
        &lt;maven.compiler.source&gt;1.6&lt;/maven.compiler.source&gt;
        &lt;maven.compiler.target&gt;1.6&lt;/maven.compiler.target&gt;
    &lt;/properties&gt;
    &lt;dependencies&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.postgresql&lt;/groupId&gt;
            &lt;artifactId&gt;postgresql&lt;/artifactId&gt;
            &lt;version&gt;9.2-1003-jdbc4&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;mysql&lt;/groupId&gt;
            &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
            &lt;version&gt;5.1.25&lt;/version&gt;
        &lt;/dependency&gt;     
        &lt;dependency&gt;
            &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
            &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
            &lt;version&gt;3.0.1&lt;/version&gt;
            &lt;scope&gt;provided&lt;/scope&gt;
        &lt;/dependency&gt;
    &lt;/dependencies&gt;
    &lt;profiles&gt;
        &lt;profile&gt;
            &lt;!-- When built in OpenShift the 'openshift' profile will be used when 
                invoking mvn. --&gt;
            &lt;!-- Use this profile for any OpenShift specific customization your app 
                will need. --&gt;
            &lt;!-- By default that is to put the resulting archive into the 'webapps' 
                folder. --&gt;
            &lt;!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html --&gt;
            &lt;id&gt;openshift&lt;/id&gt;
            &lt;build&gt;
                &lt;finalName&gt;test&lt;/finalName&gt;
                &lt;plugins&gt;
                    &lt;plugin&gt;
                        &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                        &lt;version&gt;2.1.1&lt;/version&gt;
                        &lt;configuration&gt;
                            &lt;outputDirectory&gt;webapps&lt;/outputDirectory&gt;
                            &lt;warName&gt;ROOT&lt;/warName&gt;
                        &lt;/configuration&gt;
                    &lt;/plugin&gt;
                &lt;/plugins&gt;
            &lt;/build&gt;
        &lt;/profile&gt;
    &lt;/profiles&gt;
&lt;/project&gt;
</code></pre>

<p>Posdata: I know how to get the war to run in its own context (<a href="http://test-testdomain.rhcloud.com/war/" rel="nofollow">http://test-testdomain.rhcloud.com/war/</a> for example).</p>

<p><strong>Update</strong>: here is my <code>rhc tail -a geoserver</code></p>

<pre><code>==&gt; app-root/logs/postgresql.log &lt;==
2016-03-23 12:51:43 GMT LOG:  shutting down
2016-03-23 12:51:43 GMT LOG:  database system is shut down
2016-03-23 12:52:01 GMT LOG:  could not bind socket for statistics collector: Permission denied
2016-03-23 12:52:01 GMT LOG:  trying another address for the statistics collector
2016-03-23 12:52:01 GMT LOG:  could not bind socket for statistics collector: Cannot assign requested address
2016-03-23 12:52:01 GMT LOG:  disabling statistics collector for lack of working socket
2016-03-23 12:52:01 GMT WARNING:  autovacuum not started because of misconfiguration
2016-03-23 12:52:01 GMT HINT:  Enable the "track_counts" option.
2016-03-23 12:52:01 GMT LOG:  database system was shut down at 2016-03-23 12:51:43 GMT
2016-03-23 12:52:01 GMT LOG:  database system is ready to accept connections

==&gt; app-root/logs/jbossews.log &lt;==
Mar 23, 2016 8:52:49 AM org.geoserver.GeoserverInitStartupListener contextDestroyed
INFO: Cleaned up javabean caches
Mar 23, 2016 8:52:50 AM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/geoserver] registered the JDBC driver [org.hsqldb.jdbc.JDBCDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Mar 23, 2016 8:52:50 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /var/lib/openshift/56f28b760c1e66c08b000209/app-root/runtime/dependencies/jbossews/webapps/geoserver.war has finished in 40,390 ms
Mar 23, 2016 8:52:50 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-127.3.223.1-8080"]
Mar 23, 2016 8:52:50 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 44333 ms
</code></pre>

<p>Also, I have checked the ${OPENSHIFT_JBOSSEWS_DIR}webapps, and I have the <code>geoserver.war</code> and the <code>ROOT.war</code>.</p>

<p><strong>Update 2</strong>: after the touch command, I <code>rhc til -a geoserver</code> again and got:</p>

<pre><code>==&gt; app-root/logs/postgresql.log &lt;==
2016-03-23 14:46:22 GMT LOG:  shutting down
2016-03-23 14:46:22 GMT LOG:  database system is shut down
2016-03-23 14:46:40 GMT LOG:  could not bind socket for statistics collector: Permission denied
2016-03-23 14:46:40 GMT LOG:  trying another address for the statistics collector
2016-03-23 14:46:40 GMT LOG:  could not bind socket for statistics collector: Cannot assign requested address
2016-03-23 14:46:40 GMT LOG:  disabling statistics collector for lack of working socket
2016-03-23 14:46:40 GMT WARNING:  autovacuum not started because of misconfiguration
2016-03-23 14:46:40 GMT HINT:  Enable the "track_counts" option.
2016-03-23 14:46:40 GMT LOG:  database system was shut down at 2016-03-23 14:46:22 GMT
2016-03-23 14:46:40 GMT LOG:  database system is ready to accept connections

==&gt; app-root/logs/jbossews.log &lt;==
Mar 23, 2016 10:47:54 AM org.geoserver.GeoserverInitStartupListener contextDestroyed
INFO: Cleaned up javabean caches
Mar 23, 2016 10:47:57 AM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/geoserver] registered the JDBC driver [org.hsqldb.jdbc.JDBCDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Mar 23, 2016 10:47:57 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /var/lib/openshift/56f28b760c1e66c08b000209/app-root/runtime/dependencies/jbossews/webapps/geoserver.war has finished in 68,308 ms
Mar 23, 2016 10:47:57 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-127.3.223.1-8080"]
Mar 23, 2016 10:47:57 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 72395 ms
</code></pre>