-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathREADME
More file actions
127 lines (74 loc) · 3.23 KB
/
Copy pathREADME
File metadata and controls
127 lines (74 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
This directory contains example of using HTML+JavaScript with REST API.
Available Files:
-----------------
HTML and JavaScript files are available in: assignment7/src/main/webapp/
1) ajaxexample.html
Once you build and deploy the application in Eclipse, you can access
this file to study how a HTML+JavaScript code can interact with REST API
using the Asynchronous JavaScript (AJAX) technology.
You can access this file at:
http://localhost:<port>/<context-root>/ajaxexample.html
This html file contains JavaScript code which makes AJAX call to the REST API,
which is available at:
http://localhost:<port>/<context-root>/assignment7/helloworld/helloworld
where the <context-root> is "/"
2) ajaxexample-snapshot.html
This HTML file is similar to ajaxexample.html with the only difference that
the <context-root> for the REST API is "assignment7-0.0.1-SNAPSHOT".
The reason why the context root is different in this case is explained below.
Using mvn to build the project:
----------------------------------
You can use mvn commands to build the project.
- Compile: mvn clean compile
- Create war: mvn package war:war
For war file generated by using mvn commands the context root is:
<artifactId>-<version> from pom.xml
In our case:
- artifactId is "assignment7"
- version is "0.0.1-SNAPSHOT"
Therefore, the context root is: assignment7-0.0.1-SNAPSHOT
The reason you need to understand these steps is explained below.
Deploying webapp to Tomcat on Cloud VM:
----------------------------------------
Till now we have used an IDE (Eclipse, Intellij) for deploying our webapps.
But for assignment7 we will be deploying our webapp on Tomcat on a Cloud VM.
We won't have access to Eclipse on a Cloud VM, but we will have to build the '.war' file
using mvn commands outlined above.
Steps for deploying a webapp to Cloud VM:
-------------------------------------------
1) Sign up for a cloud provider
2) Create cloud server:
E.g.: <Ubuntu 14.04, Standard flavor> on Rackspace (https://developer.rackspace.com/signup/)
3) Login
4) Install required software and packages
- apt-get update
- Install Tomcat
- apt-get install tomcat7 (This will install tomcat in /var/lib/tomcat7)
- Start Tomcat
./var/lib/tomcat7/bin/startup.sh
- Find IP address of your VM
- Via control panel
- Via command line (ifconfig and eth0)
- Access tomcat
- curl <IP-address>:8080
5) Generate war file
- Install git: apt-get install git
- Use git to clone your code from bitbucket/github
- Install maven: apt-get install maven
- Install open-jdk-7: apt-get install openjdk-7-jdk
- Compile: mvn clean compile
- Create war: mvn package war:war
- Copy assignment7-0.0.1-SNAPSHOT.war to /var/lib/tomcat7/webapps/
6) Tomcat related:
- Logs are available at:
/var/lib/tomcat7/logs/catalina.out
- Check the logs using: tail –f catalina.out
- Tomcat server port can be modified as follows:
- In /var/lib/tomcat7/conf/server.xml
- change Connector element’s port attribute
- Stop Tomcat:
./var/lib/tomcat7/bin/shutdown.sh
- Start Tomcat:
./var/lib/tomcat7/bin/startup.sh
7) Access application at:
http://<IP-address>:8080/assignment7-0.0.1-SNAPSHOT/assignment7/helloworld/helloworld