reset password
Author Message
p0941
Posts: 95
Posted 21:53 May 16, 2013 |

Hi Dr. Sun, 

What's the best strategy for deploying the spring webapp to a remote tomcat server? This question maybe a little of of scope of the class, but useful in real world situation. 

Thank you

 

cysun
Posts: 2935
Posted 08:30 May 17, 2013 |

See http://tomcat.apache.org/tomcat-7.0-doc/deployer-howto.html.

First of all you should package the web application into a WAR file, then use one of the three ways to deploy:

(a) copy the WAR file to Tomcat's webapp folder. Restart Tomcat to load the application or configure Tomcat to automatically detect and load the application. This is my preferred way of deployment.

(b) Use Tomcat Manager. This is probably the easiest way - you can simply upload the WAR file using Tomcat Manager. I don't use this out of security concerns because Tomcat Manager is an extra point of attack for potential hackers.

(c) Use Tomcat Client Deployer. I don't know about this one as I never used it before.

p0941
Posts: 95
Posted 09:11 May 17, 2013 |

I am not the server administrator and am exposed to a "www" directory only, like in the case of CS320. How do I deploy the .war file in this case? Just drop it under "www"? 

Thank you!

cysun
Posts: 2935
Posted 09:22 May 17, 2013 |
p0941 wrote:

I am not the server administrator and am exposed to a "www" directory only, like in the case of CS320. How do I deploy the .war file in this case? Just drop it under "www"? 

Thank you!

Then you deploy it like in CS320, which is copying the files over individually into the right folders under www. You can't use a WAR file because it requires access to the webapp folder, which is a level above www (which I assume is your application folder).
 

p0941
Posts: 95
Posted 11:05 May 17, 2013 |

 

Thanks, I did go back to the cs320 instruction for deploying under "www", but the spring app(from SHAM example) is structured is a little different from the directory structure in the instruction. 

For example,

  • All the files and subfolders under the project build/classes folder should be transferred to the www/WEB-INF/classes folder under your CS3 account.
  • All the files and subfolders under the project WebContent folder, excluding the META-INF subfolder, should be transfered to the www folder under your CS3 account.

  1) I opened my .war file and found WEB-INF and its WEB-INF/classes, WEB-INF/libs subfolder and other .jsp and web.xml, so I just transfer the whole WEB-INF folder under "www".    

      2) I transfered my index.jsp, which is at the same level of WEB-INF, under "www". So now under "www" I have one WEB-INF folder and one index.jsp

      Does this look OK? But when I tried to access the domain,(an address like: aa.bb.cc.com), I only got a listing of my directory, not the index.jsp I expect.

 

cysun
Posts: 2935
Posted 14:11 May 17, 2013 |
p0941 wrote:

 

Thanks, I did go back to the cs320 instruction for deploying under "www", but the spring app(from SHAM example) is structured is a little different from the directory structure in the instruction. 

For example,

  • All the files and subfolders under the project build/classes folder should be transferred to the www/WEB-INF/classes folder under your CS3 account.
  • All the files and subfolders under the project WebContent folder, excluding the META-INF subfolder, should be transfered to the www folder under your CS3 account.

  1) I opened my .war file and found WEB-INF and its WEB-INF/classes, WEB-INF/libs subfolder and other .jsp and web.xml, so I just transfer the whole WEB-INF folder under "www".    

      2) I transfered my index.jsp, which is at the same level of WEB-INF, under "www". So now under "www" I have one WEB-INF folder and one index.jsp

      Does this look OK? But when I tried to access the domain,(an address like: aa.bb.cc.com), I only got a listing of my directory, not the index.jsp I expect.

The file locations are correct. What does the directory listing show? If it shows the WEB-INF folder, your server is not running Tomcat (it's probably just running Apache). You need to ask your server admin how you should deploy your webapp.

p0941
Posts: 95
Posted 16:29 May 17, 2013 |

I will check with administrator, thank you! Have a great weekend.