javatomcatjakarta-eeopenshiftdeploying

deploy a java-ee application which was in openshift, on tomcat 7


I'm new in Java EE and Tomcat.

I worked on a REST Java application in OpenShift with JBoss EWS 2.0 and I had no problem. Recently, we got a server that I have to run my web service on.

Following How to deploy a war file in Tomcat 7, I went to my application root and used this command:

jar -cvf myapp.war *

Note that myapp is my application name for example.

I put the .war file to /base/path/of/tomcat/webapps/ and went to Tomcat GUI App Manager.

I saw that Tomcat created a folder with my .war name and put files into it, so I started my app but when I went to http://localhost:8080/myapp/ it returned 404. However, in OpenShift, when I opened it (opened root path), it displayed the index.html insomuch my webservice path is not valid and does not work.

please guide me and thank you for your time spent on my question.


Solution

  • it is simple.

    there is two way to deploy a war file on tomcat with custom path

    the first one is to renaming your war file to custom URL you want (for example the war file name is java-web-app-1.0.war and your path is myapp so you have to rename it to myapp.war)

    and copy and put it under {tomcat-path}/webapps/, then the Tomcat/TomEE does its job. (it creates an empty directory with the same name of your war file)

    after about 1 minutes you can check the path (in this example must be localhost:8080/myapp and see your war file was deployed)

    the second one is to use Tomcat GUI.

    go to Web Application Manager part.

    it's a page like this:

    enter image description here

    in Deploy box just fill the Context field (it will be the custom path and in this case is myapp) and then choose the war file and push deploy button.(do not need to fill XML Configuration file URL field)

    then it gives you a message like this:

    enter image description here

    this means your war file was deployed on the custom path.