Wiki source code of Deployment-Book

Version 16.1 by Pascal Robert on 2011/05/08 23:41

Hide last authors
Pascal Robert 6.1 1 == Using Apache: Develop Like you Deploy ==
2
Pascal Robert 16.1 3 Most of the WebObjects deployments are done in a UNIX (Mac OS X, Linux, BSD) environments, and most of the time deployment also involve Apache httpd. Since you are probably developing your applications on a Mac OS X box and Apache httpd come bundled with it, it's really easy to setup a deployment-like setup on your development box. You can also get a small deployment environment by renting a VM on services like Amazon EC2 or Linode.
4
5 Deployment typically need the following tools:
6
7 * A Web server (Apache httpd)
8 * A Web server module (mod//webobjects for Apache)//
9 * wotaskd
10 * JavaMonitor
11
12 For a deployment-like environment on your deployment box, JavaMonitor is not needed, but you do need wotaskd, the Web server and the module. (link to apache setup in the wiki)
13
Pascal Robert 6.1 14 == Why Deployment at the Beginning? ==
15
Pascal Robert 16.1 16 You might wondering: why bother with deployment so early one? So of the reasons are:
17
18 * You can use features like mod//rewrite, which are not available when using DirectConnect.//
19 * You can detect deployment problems early on. Nothing is worst than finding deployment problems when you deploy it and found out that you forgot a lot of things.
20 * You can use static content or scripts (PHP, etc.) that are not bundled in your applications.
21
Pascal Robert 6.1 22 == Structure of .framework and .woa Build Products ==
23
Pascal Robert 16.1 24 {{code}}
25
26 .framework
27 -> Resources
28 -> English.lproj, ...
29 -> ValidationTemplate.strings, Localizable.strings
30 -> .wo, .api
31 -> CustomInfo.plist
32 -> Info.plist
33 -> Java
34 -> Properties
35 -> *.eomodeld
36 -> WebServerResources
37 -> English.lproj, ...
38 -> .css/.png
39 -> .css/.png
40
41 {{/code}}
42
43 {{code}}
44
45 .woa
46 -> AppName
47 -> AppName.cmd
48 -> WOBootstrap.jar
49 -> Content
50 -> Frameworks
51 -> Info.plist
52 -> MacOS
53 -> MacOSClassPath.txt
54 -> MacOSXServerClassPath.txt
55 -> Resources
56 -> English.lproj, ...
57 -> ValidationTemplate.strings, Localizable.strings
58 -> .wo, .api
59 -> CustomInfo.plist
60 -> Java
61 -> *.eomodeld
62 -> Properties
63 -> UNIX
64 -> UNIXClassPath.txt
65 -> WebServerResources
66 -> English.lproj, ...
67 -> .css/.png
68 -> Windows
69 -> CLSSPATH.TXT
70 -> SUBPATHS.TXT
71
72 {{/code}}
73
Pascal Robert 6.1 74 == WebObjects and Classpaths ==
75
Pascal Robert 16.1 76 The classpath that your applications use can be different in development and deployment, and that's one of the reasons why you should create a deployment environment early on. The WebObjects runtime includes the following directories when you deploy your applications:
77
Pascal Robert 6.1 78 == Organizing Deployments ==
79
80 == Apache Configuration ==
81
82 == SSL Configuration ==
83
Pascal Robert 16.1 84 It's useful to create a https configuration on your deployment-like setup. By doing that, you can try out switching between SSL and non-SSL and make sure that switching is working well. On your development box, no need to purchase a SSL certificate, you can create a self-signed certificate for free. To create a self-signed certificate on OS X, do the following:
85
86 {{code}}
87
88 # sudo openssl genrsa -out /etc/apache2/localhost.key 2048
89
90 # sudo openssl req -new -key /etc/apache2/localhost.key -out /etc/apache2/localhost.csr
91 Country Name (2 letter code) [AU]: <your country code, eg: CA, US, etc.>
92 State or Province Name (full name) [Some-State]: <full name of province or state>
93 Locality Name (eg, city) []: <full city name>
94 Organization Name (eg, company) [Internet Widgits Pty Ltd]: <your name>
95 Organizational Unit Name (eg, section) []:
96 Common Name (eg, YOUR name) []:localhost
97 Email Address []: <your email address>
98
99 # sudo openssl x509 -req -days 365 -in /etc/apache2/localhost.csr -signkey /etc/apache2/localhost.key -out /etc/apache2/localhost.crt
100
101 # sudo chmod 600 /etc/apache2/localhost.key
102
103 {{/code}}
104
105 You know have a self-signed certificate that will be valid for 365 days. When your certificate expires, you only need to run the last command to generate a new one, no need to recreate a key or certificate request.
106
107 Now, let's add that certificate to Apache configuration. Edit /etc/apache2/httpd.conf, and at the end, add:
108
109 {{code}}
110
111 Listen 127.0.0.1:443
112 NameVirtualHost 127.0.0.1
113 <VirtualHost 127.0.0.1:443>
114 DocumentRoot "/Library/WebServer/Documents/"
115 ServerName localhost
116 <Directory "/Library/WebServer/Documents/">
117 allow from all
118 Options +Indexes
119 </Directory>
120 SSLEngine on
121 SSLProtocol +SSLv3 +TLSv1
122 SSLCertificateFile /private/etc/apache2/localhost.crt
123 SSLCertificateKeyFile /private/etc/apache2/localhost.key
124 </VirtualHost>
125
126 {{/code}}
127
128 And restart Apache:
129
130 {{code}}
131
132 apachectl configtest
133 apachectl restart
134
135 {{/code}}
136
Pascal Robert 8.1 137 == Deployment Components: JavaMonitor, Wotaskd and javawoservice ==
Pascal Robert 6.1 138
139 == Setting up JavaMonitor ==
140
141 == Editing spawnofwotaskd.sh ==
142
143 == Configuring an Application ==
144
Pascal Robert 16.1 145 * By using JavaMonitor's GUI
146 * By using JavaMonitor's REST services
147
Pascal Robert 6.1 148 == Logging and Permissions ==
149
Pascal Robert 16.1 150 Permissions are a typical deployment problem that arise from time to time in the mailing lists. By default, on deployment boxes, applications are running under the "appserver" user, but when you upload your application to your deployment server, the script that launch your application will be owned by the user who uploaded the application and "appserver" might not be able to launch the application. If your application doesn't launch and you don't get any logging going on, good chance that the problem is related to permissions on the launch script.
151
Pascal Robert 6.1 152 == Optimization: Adjusting Timeouts, Memory Usage, and Number of Instances ==
153
154 == Trouble Shooting: Where to look when things go wrong ==
155
Pascal Robert 16.1 156 The first thing to do when an application doesn't launch by JavaMonitor/wotaskd is to launch it by command line. To do so, open a command line shell, logging as the "appserver" and start the launch script manually. For example, if you have an application named "MyApp.woa" in /Library/WebObjects/Applications, do the following commands:
157
158 * sudo s
159 * su - appserver
160 * cd /Library/WebObjects/Applications/MyApp.woa
161 * ./MyApp
162
163 99% of the time, that procedure will show the problems, in particular permissions and classpath problems.
164
Pascal Robert 12.1 165 == Deployment alternatives (servlet, mod//proxy)// ==
Pascal Robert 10.1 166
Pascal Robert 16.1 167 == Handling Transitions between http and https ==
Pascal Robert 10.1 168
Pascal Robert 16.1 169 == Using Jenkins for builds ==
170
171 Using a continuous build system is useful. Many people in the community don't even build their applications on their development boxes anymore, they use a continuous build system to build projects from a source control repository. This is even more useful if you have more than one developer working on your projects, by centralizing builds, you can detect source merge problems, etc. You can even run unit tests and do deployments from a build system.
172
173 The most popular continuous build system is Jenkins. It's an open source project build in Java, with many useful plugins.
174
175 == Using a staging server ==
176
177 It's not a requirement early on, but if your development and development environments are not alike (for example: development on OS X, deployment on Linux), you should create a staging environment that is setup exactly like your production environment. By "exactly", we means that for instance if your production environment is using CentOS 5 64bits (x86//64), your staging environment should use the same OS, and the same version of Apache, etc. A staging environment will allow your customers to try new versions of your apps without putting them on your production server, and you can detect environment-specific problems.//