1

Issues with Tomcat deployment in a Cpanel/WHM server.

I was trying to deploy multiple java war files in a Cpanel server but was stuck with many things. I have searched many articles and tried implementing that but none worked. Please see below.

  1. Which is the exact location that you want to deploy the java war file. Is it the /home/user/public_html or /usr/local/easy/share/easy-tomcat7/webapps.

  2. For me i have deployed the war file in /usr/local/easy/share/easy-tomcat7/webapps directory. We have placed the war file in this location and restarted tomcat from WHM and the file got deployed automatically. Is this how we should do?

  3. I was able to deploy a single war file and I have made the port change from 8080 to 80 in the server.xml file and it was working fine. But when I tried to deploy multiple war files it is causing issues. Please let me know we need to deploy multiple war files in a Cpanel server?

  4. Also Once the war file got deployed then we have made few code changes in the files inside the directory to change the path from local path to server path. But the war file gets deployed each time when the tomcat gets restarted.

The war file was earlier deployed in tomcat 5.5 version and now we are trying to deploy this in tomcat 7. We have stopped the httpd service on the server and the port 80 is listened by tomcat. Also in the catalina.out file no particular errors are shown as it is mentioned that every thing loaded. Please let me know how we need to deal with the above steps so that i proceed to the next. Thanks in Advance.

seenukarthi
  • 8,241
  • 10
  • 47
  • 68

1 Answers1

2

Which is the exact location that you want to deploy the java war file. Is it the /home/user/public_html or /usr/local/easy/share/easy-tomcat7/webapps.

Answer : The correct location is /usr/local/easy/share/easy-tomcat7/webapps. The other location is for " Apache HTTP Server" which supports php html etc.

2.For me i have deployed the war file in /usr/local/easy/share/easy-tomcat7/webapps directory. We have placed the war file in this location and restarted tomcat from WHM and the file got deployed automatically. Is this how we should do?

You could always hot deploy . Meaning no need to restart. Set autoDeploy="true" on the Host element in server.xml. From my experience, i prefer restarting tomcat after deployment .

3.I was able to deploy a single war file and I have made the port change from 8080 to 80 in the server.xml file and it was working fine. But when I tried to deploy multiple war files it is causing issues. Please let me know we need to deploy multiple war files in a Cpanel server?

Ans The apache HTTP webserver uses port 80 by default. so if you change the tomcat port to 80 then make sure you change apache HTTP server port to something else. Also changing port of Apache tomcat is a bad for security. check on google why. The normal practise is to run apache HTTP server as proxy and forward jsp request from apache to Tomcat. This requires some server administration skills.

  1. Also Once the war file got deployed then we have made few code changes in the files inside the directory to change the path from local path to server path. But the war file gets deployed each time when the tomcat gets restarted.

Not really clear what you meant. But if auto deployment is on some changes are automatically updated. I would usually down tomcat. delete the previous war file and removed the extracted folder and then redeploy the new changed war file. Works for me as in the env i work few minutes of downtime is ok. Change your steps according to your requirement. No need to stop http service . just change port of http service to other than 80. and tomcat will work on port 80.

My suggestion for you is to follow these steps

  1. First make sure your app is working fine in localhost or local machine.

  2. If it is working in localhost and any error in server. check version of tomcat on both machines and see if that is what you are aiming for.

  3. Make sure tomcat is working on the server. Check if it is listening on port 8080(default).Then upload you example.war file to webapps folder. Restart tomcat.

  4. Wait for two minutes.Check if your example.war is working from link www.yourdomainname.com:8080/example .

  5. If it is not working , debug errors and resolve it. (This step is considered bad practice for security. just mentioning it as a testing step )If working then you could try changing port of apache http server from 80 to somethings else(make sure port unused) . then change port of tomcat to 80. Then rename your example example.war to ROOT.war inside webapp . delete previous exiting ROOT directory. restart apache http server then tomcat. see if tomcat is listening in port 80 then try if your app is working from www.yourdomainname.com. If yes then it is good.

  6. Now we need to retrace previous step as running tomcat on port 80 is considered bad for security. if it is ok in the environment you deploy then you could use this setup. Correct normal practise is put Apache HTTp server on port 80: configure apache http server to redirect .jsp request to apache tomcat on port 8080. make tomcat port 8080. But this requires some system admin expertise.

Raj
  • 1,945
  • 20
  • 40
  • Thank you Raj for the Reply. As mentioned I have changed the tomcat port back to 8080. In server.xml file the autoDeploy is kept true and once i moved the single war file to this location it got autodeployed but when i tried to start this from the tomcat interface it is was showing errors like. "FAIL - Application at context path /MySite could not be started" [Name replaced to MySite]. I have checked the catalina.err and found the following errors. Please see the comment below. – Sandeep Sasikumar Apr 07 '15 at 06:54
  • ERROR SHOWN "org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc SEVERE: The web application [/MySite] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. org.apache.catalina.loader.WebappClassLoader clearReferencesThreads SEVERE: The web application [/MySite] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak." – Sandeep Sasikumar Apr 07 '15 at 06:55
  • Regarding "SEVERE: The web application [/MySite] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it " I think this is kind of an information message. letting you know tomcat has done something. Most probably your site should still work . There are many page on internet which goes more into this. Check link http://stackoverflow.com/questions/3320400/to-prevent-a-memory-leak-the-jdbc-driver-has-been-forcibly-unregistered and also link http://ask.webatall.com/java/1912_to-prevent-a-memory-leak-the-jdbc-driver-has-been-forcibly-unregistered.html – Raj Apr 07 '15 at 07:33
  • 1
    Thank you Raj for the comments. I was able to deploy both war files and was able to start it. One domain is pointing correctly and other domain is redirecting towards the default tomcat page. Can you please tell me why is it so?. I can access the website when i access it with the full website URL. For example: www.Domain2.com/folder/index.html but not www.Domain2.com. I am really trying to implement mod_proxy to redirect port 80 request to 8080 but none of my tries are working fine. I am using the Cpanel server. Is there any way i can install that from Cpanel and configure mod_proxy? – Sandeep Sasikumar Apr 08 '15 at 10:21
  • Hi Raj, Also is there any was i can implement the SSL certificate for this domain. I have installed SSL certificates running in apache but not done with tomcat. Do i have to make any change if i implement mod_proxy to redirect requests. I read documents mentioning to change the settings in server.xml that forwards requests for SSL to 8443. Will this be same if i implement it using mod_proxy. Thanks in advance Raj for the support. – Sandeep Sasikumar Apr 08 '15 at 10:26
  • To host multiple war files with different domain names you need to configure something called virtual host. By default for www.example.com tomcat finds the war file www.example.com/ROOT.war To have multiple domains point to different war files you need to configure virtual host . It is easy. Plz go through the links below http://stackoverflow.com/questions/10704833/tomcat-and-multiple-domains-applications http://www.ramkitech.com/2012/02/understanding-virtual-host-concept-in.html https://tomcat.apache.org/tomcat-7.0-doc/virtual-hosting-howto.html – Raj Apr 09 '15 at 06:00
  • Regarding SSL and mod_proxy, i think you could get better answers from http://www.serverfault.com/ . – Raj Apr 09 '15 at 06:06
  • Thank you Raj for the wonderful support. I believe i have learned a lot from the comments and articles you shared. I was able to deploy both war files on the server. Regarding SSL configuration i have generated the keystore and CSR from tomcat and installed the SSL certificate on the server for my website. But i think i will be able to check the SSL certificate only after i make the website live. I have been testing the deployed website by making the entry in my /etc/hosts file. I am not able to vote for your comments as it is showing that i need 15 reputations for this. – Sandeep Sasikumar Apr 10 '15 at 12:21
  • Hi, I was trying to install SSL certificate in tomcat from my website. I have already tried installating the SSL certificate by running the below mentioned 3 steps. 1) keytool -import -alias root -keystore tomcat.keystore -trustcacerts -file .crt 2) keytool -import -alias intermed -keystore tomcat.keystore -trustcacerts -file .crt 3)keytool -import -alias tomcat -keystore tomcat.keystore -trustcacerts -file .crt But it is still showing the self signed one and also it is redirecting me to the cgi-sys/defaultwebpage.cgi. Please let me know the issue. – Sandeep Sasikumar May 26 '15 at 06:31