Deployment runthrough on Windows » History » Version 16

Chris Cannam, 2014-09-30 05:23 PM

1 1 Chris Cannam
h1. Deployment runthrough on Windows
2 1 Chris Cannam
3 5 Chris Cannam
This is an example deployment on a 32-bit Windows 7 host.
4 1 Chris Cannam
5 5 Chris Cannam
See [[Deployment runthrough]] for a typical Linux deployment.
6 5 Chris Cannam
7 15 Chris Cannam
See [[Deployment troubleshooting]] for notes about Java and Tomcat versions and on things that might go wrong (mostly from a Linux perspective).
8 5 Chris Cannam
9 14 Chris Cannam
Note: If you don't have admin privileges on the Windows host (i.e. can't install to @C:\Program Files@ it is still possible to do this by installing to your home directory, but several details may change and that setup has not been tested in this runthrough.
10 14 Chris Cannam
11 1 Chris Cannam
h2. 1. Obtain the current code from Mercurial repository
12 3 Chris Cannam
13 1 Chris Cannam
I use "EasyMercurial":http://easyhg.org/ as my Windows Mercurial client. Use "Open" -> "Remote repository" and provide @https://code.soundsoftware.ac.uk/hg/human-echolocation-java-webapp@ as the remote repository URL, cloning to a folder called @human-echolocation-java-webapp@ in my Documents folder. (See "screenshot":/attachments/download/1182/Screenshot%20-%20300914%20-%2008_51_01.png.)
14 3 Chris Cannam
15 1 Chris Cannam
h2. 2. Install the MATLAB Compiler Runtime
16 1 Chris Cannam
17 5 Chris Cannam
Navigate to http://www.mathworks.co.uk/products/compiler/mcr/ and find the download URL. (I am using release R2013b here.) Download and run the installer, accepting its default installation path of @C:\Program Files\MATLAB\MATLAB Compiler Runtime@.
18 5 Chris Cannam
19 11 Chris Cannam
h2. 3. Install Java, Tomcat, and Ant
20 1 Chris Cannam
21 11 Chris Cannam
h3. Java
22 11 Chris Cannam
23 1 Chris Cannam
Navigate to http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html to download (in our case) Java 7 JDK. Run the installer and install to the default path.
24 1 Chris Cannam
25 11 Chris Cannam
Now make sure the JAVA_HOME environment variable points to the JDK just installed, and not to the JRE runtime (this is necessary for use of the Ant build tool later). To do this, go to the Windows Control Panel, search for "environment" and open the environment variable dialog. Add a new user environment variable setting JAVA_HOME to the JDK location. (See "screenshot":/attachments/download/1184/Screenshot%20-%20300914%20-%2010_24_01.png)
26 1 Chris Cannam
27 11 Chris Cannam
h3. Tomcat
28 11 Chris Cannam
29 11 Chris Cannam
Apache Tomcat is a web application server commonly used for Java servlet applications.
30 11 Chris Cannam
31 10 Chris Cannam
Navigate to http://tomcat.apache.org/ and download the "32-bit/64-bit Windows Service installer" for (in our case) Tomcat 7. Again we accept the default path (@C:\Program Files\Apache Software Foundation\Tomcat 7.0@). Note that the installer asks you to set a username and password for the Tomcat administrator login -- this is optional, but it will save some configuration later if you set a password now. (See "screenshot":/attachments/download/1183/Screenshot%20-%20300914%20-%2010_05_03.png)
32 1 Chris Cannam
33 1 Chris Cannam
When installation is complete, you will be given the option to start Tomcat -- accept it. You should then be able to open the URL @http://127.0.0.1:8080/manager/html@ in a browser to see the Tomcat manager page. You will be asked for a username and password to access it -- these should be the same ones you provided during installation.
34 1 Chris Cannam
35 11 Chris Cannam
h3. Ant
36 10 Chris Cannam
37 11 Chris Cannam
Apache Ant is the tool used to build the webapp project. (One could install an entire development environment such as Eclipse, as well, but that is beyond the scope of this page!)
38 10 Chris Cannam
39 11 Chris Cannam
Navigate to http://ant.apache.org/bindownload.cgi and download the Zip archive of the current version of Ant. Unpack it anywhere you like, but make a note of the path. I am unpacking it and copying the @apache-ant-1.9.4@ folder into @C:\Program Files\Apache Software Foundation@ next door to Tomcat.
40 10 Chris Cannam
41 11 Chris Cannam
h2. 4. Bring dependent JAR files into the webapp folder
42 10 Chris Cannam
43 12 Chris Cannam
Copy @C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib\servlet-api.jar@ into the @human-echolocation-java-webapp@ folder.
44 1 Chris Cannam
45 12 Chris Cannam
Copy @C:\Program Files\MATLAB\MATLAB Compiler Runtime\v82\toolbox\javabuilder\jar\javabuilder.jar@ into the @human-echolocation-java-webapp\WebContent\WEB-INF\lib@ folder.
46 1 Chris Cannam
47 16 Chris Cannam
h2. 5. Configure the application paths
48 1 Chris Cannam
49 16 Chris Cannam
Edit the file @human-echolocation-java-webapp\WebContent\WEB-INF\classes\HumanEcho.properties@ and set the @indir@ and @outdir@ properties to appropriate paths. 
50 16 Chris Cannam
51 16 Chris Cannam
The @indir@ path must be a specific location (@webapps\\echoapp\\WEB-INF\\data@) relative to the Tomcat webapp root, and @outdir@ can be any directory path that does not already exist and that the Tomcat process will have permission to create.
52 16 Chris Cannam
53 16 Chris Cannam
Both paths must have Windows path format (with drive prefix and backslash separator) and the backslashes must be escaped, like so:
54 16 Chris Cannam
55 16 Chris Cannam
<pre>
56 16 Chris Cannam
indir=C:\\Program Files\\Apache Software Foundation\\Tomcat 7.0\\webapps\\echoapp\\WEB-INF\\data
57 16 Chris Cannam
outdir=C:\\tmp\\wav
58 16 Chris Cannam
</pre>
59 16 Chris Cannam
60 16 Chris Cannam
h2. 6. Build the WAR file bundle
61 16 Chris Cannam
62 12 Chris Cannam
Open a Command Prompt window and cd to the @human-echolocation-java-webapp@ folder. Then run Ant:
63 12 Chris Cannam
64 12 Chris Cannam
<pre>
65 13 Chris Cannam
C:\Users\Chris\Documents\human-echolocation-java-webapp>"c:\Program Files\Apache Software Foundation\apache-ant-1.9.4\bin\ant"
66 12 Chris Cannam
Buildfile: C:\Users\Chris\Documents\human-echolocation-java-webapp\build.xml
67 1 Chris Cannam
68 1 Chris Cannam
build:
69 12 Chris Cannam
    [javac] Compiling 2 source files to C:\Users\Chris\Documents\human-echolocation-java-webapp\WebContent\WEB-INF\classes
70 12 Chris Cannam
71 13 Chris Cannam
ir:
72 12 Chris Cannam
     [copy] Copying 1 file to C:\Users\Chris\Documents\human-echolocation-java-webapp\WebContent\WEB-INF\data
73 12 Chris Cannam
74 13 Chris Cannam
build-war:
75 12 Chris Cannam
      [war] Building war: C:\Users\Chris\Documents\human-echolocation-java-webapp\echoapp.war
76 12 Chris Cannam
77 12 Chris Cannam
BUILD SUCCESSFUL
78 12 Chris Cannam
Total time: 1 second
79 1 Chris Cannam
80 14 Chris Cannam
C:\Users\Chris\Documents\human-echolocation-java-webapp>
81 1 Chris Cannam
</pre>
82 14 Chris Cannam
83 16 Chris Cannam
h2. 7. Deploy the bundle
84 14 Chris Cannam
85 14 Chris Cannam
Copy the file @echoapp.war@ from the @human-echolocation-java-webapp@ folder into the Tomcat applications folder at @C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps@.
86 14 Chris Cannam
87 14 Chris Cannam
If the Tomcat service was already running -- as it should have been -- then Tomcat will automatically unbundle and deploy the WAR file. (You should see an @echoapp@ folder being created automatically in the @webapps@ folder when you paste in the WAR file.)
88 1 Chris Cannam
89 14 Chris Cannam
Now navigate again to http://127.0.0.1:8080/manager/html in a browser (or reload the page if you already have it open). You should see @/echoapp@ listed as an application. If it is not running, click the Start button next to it.
90 14 Chris Cannam
91 16 Chris Cannam
h2. 8. Test the app
92 14 Chris Cannam
93 14 Chris Cannam
Navigate to http://127.0.0.1:8080/echoapp/ in your browser. You should see the Human Echolocation Webapp front page.