Question

Question 1: May I ask what is the difference between deploying a java webapp with it's WAR file vs just copy/pasting the build folder into tomcat webapp folder?

Question 2: Somehow I am told to deploy my project just by renaming my /build/web folder to /build/, then copy and paste this folder into tomcat/webapp folder. Tomcat did serve the web app and I could access it via url. But the problem is that I suspect my System variables were not set. I start up a servlet and put this code in this init(ServletConfig config) method:

System.setProperty("LogPath","D:/Test/logs");

And doing this in my log4j.properties

log4j.appender.file.FILE=${LogPath}/wrapper.log

wrapper.log is not found in the designated directory but a stdout.log is found in tomcat/logs folder.

I am sure the init() method was fired because I have a quartz scheduler there. I am suspecting that my System.setProperty was not set. Any hint?

Update: With all the same source code, I have no problem if I am deploying with a WAR file. The ${LogPath} in log4j.properties work as expected.

Was it helpful?

Solution

Let me answer you the first question.

WAR file is a zip archive with different name. When you deploy this file to the Tomcat server, it unpacks this file to its folder as you would do it by copy-paste. If you are just developing your own project in your own environment and you don't want to distribute it, you don't need to create a war file. But if you want to distribute this project, I recommend you to create a war file. One file is easier to be sent.

Read more on Wikipedia http://en.wikipedia.org/wiki/WAR_%28file_format%29

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top