Testing spring openshift application locally
java, jboss, openshift, spring, tomcat
Solution
This is how i ended up doing. I renamed the original `web.xml` file, with something like `web-openshift.xml`. When projects are built in OpenShift, the maven `openshift` profile is used. You can find it in your `<profiles>` section in pom.xml. So i added a line to my `pom.xml`:
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
....
<webXml>src/main/webapp/WEB-INF/web-openshift.xml</webXml> <!--add this-->
This makes the `maven-war-plugin` to use the `web-openshift.xml` file as the web deployment descriptor when building the war. Then i added a `web.xml` file, which will be used for my local build. In those files you configure your servlets with:
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/jboss-as-spring-mvc-context.xml</param-value>
So by changing the `<param-value>` in my two `web.xml` files, I was able to configure Spring and Hibernate in different ways.
Then I added the jars marked as `<provided>` in `pom.xml` to the `\lib` directory of my Tomcat installation. Now i am able to deploy and run the application both to OpenShift and Tomcat.
Problem
I have an application running on Openshift. It works fine, but testing is difficult because i have to push every little thing to openshift and wait for all the building and restarting to see the changes. So i am trying to find a way to test the application locally. Another guy asked the same thing here: How to test an openshift application on local host, but i am wondering if an easier solution exists. I used the quickstart project here http://github.com/openshift/spring-eap6-quickstart.git to start it. So basically it is a Spring application using Hibernate. What i have in mind to have two sets of configuration files (`persistence.xml` etc.) in the project, one for local Tomcat server and one for Jboss eap and change `web.xml` according to the server i want to deploy to. Is this doable? Looks so simple, i am afraid of any surprise problems before changing the project.