forked from jboss-developer/ticket-monster
-
Notifications
You must be signed in to change notification settings - Fork 7
/
README.html
197 lines (154 loc) · 21.1 KB
/
README.html
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<!DOCTYPE html><html><head><title>README</title><link href="http://www.jboss.org/jdf/stylesheets/documentation.css" rel="stylesheet"></link><link href="http://www.jboss.org/jdf/stylesheets/pygments.css" rel="stylesheet"></link></head><body>
<h1><a id="ticketmonster-a-jboss-example" class="anchor" href="#ticketmonster-a-jboss-example"><span class="anchor-icon"></span></a>TicketMonster - a JBoss example</h1>
<p>TicketMonster is an online ticketing demo application that gets you started with JBoss technologies, and helps you learn and evaluate them.</p>
<p>Here are a few instructions for building and running it. You can learn more about the example from the <a href="http://www.jboss.org/ticket-monster">tutorial</a>.</p>
<h2><a id="updating-the-performance-dates" class="anchor" href="#updating-the-performance-dates"><span class="anchor-icon"></span></a>Updating the Performance dates</h2>
<p><em>NOTE: This step is optional. It is necessary only if you want to update the dates of the Performances in the <code>import.sql</code> script in an automated manner. Updating the performance dates ensure that they are always set to some timestamp in the future, and ensures that all performances are visible in the Monitor section of the TicketMonster application.</em></p>
<ol>
<li><p>Run the <code>update_import_sql</code> Perl script. You’ll need the <code>DateTime</code>, <code>DateTime::Format::Strptime</code> and <code>Tie::File</code> Perl modules. These are usually available by default in your Perl installation.</p>
<div class="highlight"><pre><span class="nv">$ </span>perl update_import_sql.pl src/main/resources/import.sql
</pre></div></li>
</ol>
<h2><a id="generating-the-administration-site" class="anchor" href="#generating-the-administration-site"><span class="anchor-icon"></span></a>Generating the administration site</h2>
<p><em>NOTE: This step is optional. The administration site is already present in the source code. If you want to regenerate it from Forge, and apply the changes outlined in the tutorial, you may continue to follow the steps outlined here. Otherwise, you can skip this step and proceed to build TicketMonster.</em></p>
<p>Before building and running TicketMonster, you must generate the administration site with Forge.</p>
<ol>
<li><p>Ensure that you have <a href="http://jboss.org/forge">JBoss Forge</a> installed. The current version of TicketMonster supports version 2.6.0.Final or higher of JBoss Forge. JBoss Developer Studio 8 is recommended, since it contains JBoss Forge 2 with all the necessary plugins for the TicketMonster app.</p></li>
<li><p>Start the JBoss Forge console in JBoss Developer Studio. This can be done from the Forge Console view. If the view is not already visible, it can be opened through the ‘Window’ menu: <em>Window</em> -> <em>Show View</em> -> <em>Other…</em>. Select the ‘Forge Console’ item in the dialog to open the Forge Console. Click the <em>Start</em> button in the Forge Console tab, to start Forge. </p></li>
<li><p>From the JBoss Forge prompt, browse to the ‘demo’ directory of the TicketMonster sources and execute the script for generating the administration site</p>
<div class="highlight"><pre><span class="nv">$ </span><span class="nb">cd </span>ticket-monster/demo
<span class="nv">$ </span>run admin_layer.fsh
</pre></div>
<p>The git patches need to be applied manually. Both the patches are located in the patches sub-directory. To apply the manual changes, first apply the patch located in file <em>admin_layer_functional.patch</em>. Then perform the same for the file <em>admin_layer_graphics.patch</em> if you want to apply the style changes for the generated administration site. You can do so in JBoss Developer Studio, by opening the context-menu on the project (Right-click on the project) and then apply a git patch via <em>Team</em> -> <em>Apply Patch…</em>. Locate the patch file in the Workspace, select it and click the ‘Next’ button. In the next dialog, select to apply the patch on the ‘ticket-monster’ project in the workspace. Click Finish in the final page of the wizard after satisfying that the patch applies cleanly.</p></li>
<li><p>Deployment to JBoss EAP 6.3 is optional. The project can be built and deployed to a running instance of JBoss EAP through the following command in JBoss Forge:</p>
<div class="highlight"><pre><span class="nv">$ </span>build clean package jboss-as:deploy
</pre></div></li>
</ol>
<h2><a id="building-ticketmonster" class="anchor" href="#building-ticketmonster"><span class="anchor-icon"></span></a>Building TicketMonster</h2>
<p>TicketMonster can be built from Maven, by runnning the following Maven command:</p>
<div class="highlight"><pre><span class="n">mvn</span> <span class="n">clean</span> <span class="n">package</span>
</pre></div>
<h3><a id="building-ticketmonster-with-tests" class="anchor" href="#building-ticketmonster-with-tests"><span class="anchor-icon"></span></a>Building TicketMonster with tests</h3>
<p>If you want to run the Arquillian tests as part of the build, you can enable one of the two available Arquillian profiles.</p>
<p>For running the tests in an <em>already running</em> application server instance, use the <code>arq-jbossas-remote</code> profile.</p>
<div class="highlight"><pre><span class="n">mvn</span> <span class="n">clean</span> <span class="n">package</span> <span class="o">-</span><span class="n">Parq</span><span class="o">-</span><span class="n">jbossas</span><span class="o">-</span><span class="n">remote</span>
</pre></div>
<p>If you want the test runner to <em>start</em> an application server instance, use the <code>arq-jbossas-managed</code> profile. You must set up the <code>JBOSS_HOME</code> property to point to the server location, or update the <code>src/main/test/resources/arquillian.xml</code> file.</p>
<div class="highlight"><pre><span class="n">mvn</span> <span class="n">clean</span> <span class="n">package</span> <span class="o">-</span><span class="n">Parq</span><span class="o">-</span><span class="n">jbossas</span><span class="o">-</span><span class="n">managed</span>
</pre></div>
<h3><a id="building-ticketmonster-with-postgresql-for-openshift" class="anchor" href="#building-ticketmonster-with-postgresql-for-openshift"><span class="anchor-icon"></span></a>Building TicketMonster with Postgresql (for OpenShift)</h3>
<p>If you intend to deploy into <a href="http://openshift.com">OpenShift</a>, you can use the <code>postgresql-openshift</code> profile</p>
<div class="highlight"><pre><span class="n">mvn</span> <span class="n">clean</span> <span class="n">package</span> <span class="o">-</span><span class="n">Ppostgresql</span><span class="o">-</span><span class="n">openshift</span>
</pre></div>
<h3><a id="building-ticketmonster-with-mysql-for-openshift" class="anchor" href="#building-ticketmonster-with-mysql-for-openshift"><span class="anchor-icon"></span></a>Building TicketMonster with MySQL (for OpenShift)</h3>
<p>If you intend to deploy into <a href="http://openshift.com">OpenShift</a>, you can use the <code>mysql-openshift</code> profile</p>
<div class="highlight"><pre><span class="n">mvn</span> <span class="n">clean</span> <span class="n">package</span> <span class="o">-</span><span class="n">Pmysql</span><span class="o">-</span><span class="n">openshift</span>
</pre></div>
<h2><a id="running-ticketmonster" class="anchor" href="#running-ticketmonster"><span class="anchor-icon"></span></a>Running TicketMonster</h2>
<p>You can run TicketMonster into a local JBoss EAP 6.3 instance or on OpenShift.</p>
<h3><a id="running-ticketmonster-locally" class="anchor" href="#running-ticketmonster-locally"><span class="anchor-icon"></span></a>Running TicketMonster locally</h3>
<h4><a id="start-jboss-enterprise-application-platform-63" class="anchor" href="#start-jboss-enterprise-application-platform-63"><span class="anchor-icon"></span></a>Start JBoss Enterprise Application Platform 6.3</h4>
<ol>
<li>Open a command line and navigate to the root of the JBoss server directory.</li>
<li><p>The following shows the command line to start the server with the web profile:</p>
<div class="highlight"><pre><span class="n">For</span> <span class="n">Linux</span><span class="o">:</span> <span class="n">JBOSS_HOME</span><span class="o">/</span><span class="n">bin</span><span class="o">/</span><span class="n">standalone</span><span class="p">.</span><span class="n">sh</span>
<span class="n">For</span> <span class="n">Windows</span><span class="o">:</span> <span class="n">JBOSS_HOME</span><span class="err">\</span><span class="n">bin</span><span class="err">\</span><span class="n">standalone</span><span class="p">.</span><span class="n">bat</span>
</pre></div></li>
</ol>
<h4><a id="deploy-ticketmonster" class="anchor" href="#deploy-ticketmonster"><span class="anchor-icon"></span></a>Deploy TicketMonster</h4>
<ol>
<li>Make sure you have started the JBoss Server as described above.</li>
<li><p>Type this command to build and deploy the archive into a running server instance.</p>
<div class="highlight"><pre><span class="n">mvn</span> <span class="n">clean</span> <span class="n">package</span> <span class="n">jboss</span><span class="o">-</span><span class="n">as</span><span class="o">:</span><span class="n">deploy</span>
</pre></div>
<p>(You can use the <code>arq-jbossas-remote</code> profile for running tests as well)</p></li>
<li><p>This will deploy <code>target/ticket-monster.war</code> to the running instance of the server.</p></li>
<li><p>Now you can see the application running at <code>http://localhost:8080/ticket-monster</code></p></li>
</ol>
<h3><a id="running-ticketmonster-in-openshift" class="anchor" href="#running-ticketmonster-in-openshift"><span class="anchor-icon"></span></a>Running TicketMonster in OpenShift</h3>
<h4><a id="create-an-openshift-project" class="anchor" href="#create-an-openshift-project"><span class="anchor-icon"></span></a>Create an OpenShift project</h4>
<blockquote>
<p>The following variables are used in these instructions. Be sure to replace them as follows:
* APP_NAME should be replaced with the name of the application you create on OpenShift.
* YOUR_DOMAIN_NAME should be replaced with the OpenShift domain name.
* APPLICATION_UUID should be replaced with the UUID generated by OpenShift for your application, for example: 52864af85973ca430200006f
* TICKETMONSTER_MAVEN_PROJECT_ROOT is the location of the Maven project sources for the TicketMonster application.</p>
</blockquote>
<ol>
<li><p>Open a shell command prompt and change to a directory of your choice. Enter the following command to create a JBoss EAP 6 application:</p>
<div class="highlight"><pre><span class="n">rhc</span> <span class="n">app</span> <span class="n">create</span> <span class="o">-</span><span class="n">a</span> <span class="n">APP_NAME</span> <span class="o">-</span><span class="n">t</span> <span class="n">jbosseap</span><span class="o">-</span><span class="mi">6</span>
</pre></div></li>
</ol>
<p>This command creates an OpenShift application named APP_NAME and will run the application inside the jbosseap-6 container. You should see some output similar to the following:</p>
<div class="highlight"><pre> <span class="n">Application</span> <span class="n">Options</span>
<span class="o">-------------------</span>
<span class="nl">Domain:</span> <span class="n">YOUR_DOMAIN</span>
<span class="nl">Cartridges:</span> <span class="n">jbosseap</span><span class="o">-</span><span class="mi">6</span> <span class="p">(</span><span class="n">addtl</span><span class="p">.</span> <span class="n">costs</span> <span class="n">may</span> <span class="n">apply</span><span class="p">)</span>
<span class="n">Gear</span> <span class="n">Size</span><span class="o">:</span> <span class="k">default</span>
<span class="nl">Scaling:</span> <span class="n">no</span>
<span class="n">Creating</span> <span class="n">application</span> <span class="err">'</span><span class="n">APP_NAME</span><span class="err">'</span> <span class="p">...</span> <span class="n">done</span>
<span class="n">Waiting</span> <span class="k">for</span> <span class="n">your</span> <span class="n">DNS</span> <span class="n">name</span> <span class="n">to</span> <span class="n">be</span> <span class="n">available</span> <span class="p">...</span> <span class="n">done</span>
<span class="n">Cloning</span> <span class="n">into</span> <span class="err">'</span><span class="n">APP_NAME</span><span class="err">'</span><span class="p">...</span>
<span class="nl">Warning:</span> <span class="n">Permanently</span> <span class="n">added</span> <span class="n">the</span> <span class="n">RSA</span> <span class="n">host</span> <span class="n">key</span> <span class="k">for</span> <span class="n">IP</span> <span class="n">address</span> <span class="err">'</span><span class="mf">54.90.10.115</span><span class="err">'</span> <span class="n">to</span> <span class="n">the</span> <span class="n">list</span> <span class="n">of</span> <span class="n">known</span> <span class="n">hosts</span><span class="p">.</span>
<span class="n">Your</span> <span class="n">application</span> <span class="err">'</span><span class="n">APP_NAME</span><span class="err">'</span> <span class="n">is</span> <span class="n">now</span> <span class="n">available</span><span class="p">.</span>
<span class="nl">URL:</span> <span class="n">http</span><span class="o">:</span><span class="c1">//APP_NAME-YOUR_DOMAIN.rhcloud.com/</span>
<span class="n">SSH</span> <span class="n">to</span><span class="o">:</span> <span class="n">APPLICATION_UUID</span><span class="err">@</span><span class="n">APP_NAME</span><span class="o">-</span><span class="n">YOURDOMAIN</span><span class="p">.</span><span class="n">rhcloud</span><span class="p">.</span><span class="n">com</span>
<span class="n">Git</span> <span class="n">remote</span><span class="o">:</span> <span class="n">ssh</span><span class="o">:</span><span class="c1">//APPLICATION_UUID@APP_NAME-YOUR_DOMAIN.rhcloud.com/~/git/APP_NAME.git/</span>
<span class="n">Cloned</span> <span class="n">to</span><span class="o">:</span> <span class="o">/</span><span class="n">Users</span><span class="o">/</span><span class="n">vineet</span><span class="o">/</span><span class="n">openshiftapps</span><span class="o">/</span><span class="n">APP_NAME</span>
<span class="n">Run</span> <span class="err">'</span><span class="n">rhc</span> <span class="n">show</span><span class="o">-</span><span class="n">app</span> <span class="n">APP_NAME</span><span class="err">'</span> <span class="k">for</span> <span class="n">more</span> <span class="n">details</span> <span class="n">about</span> <span class="n">your</span> <span class="n">app</span><span class="p">.</span>
</pre></div>
<ol>
<li>The create command creates a git repository in the current directory with the same name as the application.</li>
</ol>
<p>You do not need the generated default application, so navigate to the new git repository directory created by the OpenShift command and tell git to remove the source and pom files:</p>
<div class="highlight"><pre> <span class="n">cd</span> <span class="n">APP_NAME</span>
<span class="n">git</span> <span class="n">rm</span> <span class="o">-</span><span class="n">r</span> <span class="n">src</span> <span class="n">pom</span><span class="p">.</span><span class="n">xml</span>
</pre></div>
<ol>
<li><p>Copy the TicketMonster application sources into this new git repository:</p>
<div class="highlight"><pre><span class="n">cp</span> <span class="o">-</span><span class="n">r</span> <span class="n">TICKETMONSTER_MAVEN_PROJECT_ROOT</span><span class="o">/</span><span class="n">src</span> <span class="p">.</span>
<span class="n">cp</span> <span class="o">-</span><span class="n">r</span> <span class="n">TICKETMONSTER_MAVEN_PROJECT_ROOT</span><span class="o">/</span><span class="n">pom</span><span class="p">.</span><span class="n">xml</span> <span class="p">.</span>
</pre></div></li>
</ol>
<h4><a id="use-mysql-as-the-database" class="anchor" href="#use-mysql-as-the-database"><span class="anchor-icon"></span></a>Use MySQL as the database</h4>
<ol>
<li><p>Add the MySQL 5.5 cartridge to the <code>ticketmonster</code> application:</p>
<div class="highlight"><pre><span class="n">rhc</span> <span class="n">cartridge</span> <span class="n">add</span> <span class="n">mysql</span><span class="o">-</span><span class="mf">5.5</span> <span class="o">-</span><span class="n">a</span> <span class="n">ticketmonster</span>
</pre></div></li>
<li><p>Configure the OpenShift build process, to use the <code>mysql-openshift</code> profile within the project POM. To do so, create a file named <code>pre_build_jbosseap</code> under the <code>.openshift/action_hooks</code> directory located in the git repository of the OpenShift application, with the following contents:</p>
<div class="highlight"><pre><span class="n">export</span> <span class="n">MAVEN_ARGS</span><span class="o">=</span><span class="s">"clean package -Popenshift,mysql-openshift -DskipTests"</span>
</pre></div></li>
<li><p>Set the executable bit for the action hook:</p>
<div class="highlight"><pre><span class="n">chmod</span> <span class="o">+</span><span class="n">x</span> <span class="n">TICKET_MONSTER_OPENSHIFT_GIT_REPO</span><span class="o">/</span><span class="p">.</span><span class="n">openshift</span><span class="o">/</span><span class="n">build_hooks</span><span class="o">/</span><span class="n">pre_build_jbosseap</span>
</pre></div></li>
</ol>
<p>On Windows, you will need to run the following command to set the executable bit to the <code>pre_build_jbosseap</code> file:</p>
<div class="highlight"><pre> <span class="n">git</span> <span class="n">update</span><span class="o">-</span><span class="n">index</span> <span class="o">--</span><span class="n">chmod</span><span class="o">=+</span><span class="n">x</span> <span class="p">.</span><span class="n">openshift</span><span class="o">/</span><span class="n">build_hooks</span><span class="o">/</span><span class="n">pre_build_jbosseap</span>
</pre></div>
<h4><a id="use-postgresql-as-the-database" class="anchor" href="#use-postgresql-as-the-database"><span class="anchor-icon"></span></a>Use PostgreSQL as the database</h4>
<ol>
<li><p>Add the PostgreSQL 9.2 cartridge to the <code>ticketmonster</code> application:</p>
<div class="highlight"><pre><span class="n">rhc</span> <span class="n">cartridge</span> <span class="n">add</span> <span class="n">postgresql</span><span class="o">-</span><span class="mf">9.2</span> <span class="o">-</span><span class="n">a</span> <span class="n">ticketmonster</span>
</pre></div></li>
<li><p>Configure the OpenShift build process, to use the <code>postgresql-openshift</code> profile within the project POM. To do so, create a file named <code>pre_build_jbosseap</code> under the <code>.openshift/action_hooks</code> directory located in the git repository of the OpenShift application, with the following contents:</p>
<div class="highlight"><pre><span class="n">export</span> <span class="n">MAVEN_ARGS</span><span class="o">=</span><span class="s">"clean package -Popenshift,postgresql-openshift -DskipTests"</span>
</pre></div></li>
<li><p>Set the executable bit for the action hook:</p>
<div class="highlight"><pre><span class="n">chmod</span> <span class="o">+</span><span class="n">x</span> <span class="n">TICKET_MONSTER_OPENSHIFT_GIT_REPO</span><span class="o">/</span><span class="p">.</span><span class="n">openshift</span><span class="o">/</span><span class="n">build_hooks</span><span class="o">/</span><span class="n">pre_build_jbosseap</span>
</pre></div></li>
</ol>
<p>On Windows, you will need to run the following command to set the executable bit to the <code>pre_build_jbosseap</code> file:</p>
<div class="highlight"><pre> <span class="n">git</span> <span class="n">update</span><span class="o">-</span><span class="n">index</span> <span class="o">--</span><span class="n">chmod</span><span class="o">=+</span><span class="n">x</span> <span class="p">.</span><span class="n">openshift</span><span class="o">/</span><span class="n">build_hooks</span><span class="o">/</span><span class="n">pre_build_jbosseap</span>
</pre></div>
<h4><a id="deploying-to-openshift" class="anchor" href="#deploying-to-openshift"><span class="anchor-icon"></span></a>Deploying to OpenShift</h4>
<ol>
<li><p>You can now deploy the changes to your OpenShift application using git as follows:</p>
<div class="highlight"><pre><span class="n">git</span> <span class="n">add</span> <span class="o">-</span><span class="n">A</span>
<span class="n">git</span> <span class="n">commit</span> <span class="o">-</span><span class="n">m</span> <span class="s">"TicketMonster on OpenShift"</span>
<span class="n">git</span> <span class="n">push</span>
</pre></div></li>
</ol>
<p>The final push command triggers the OpenShift infrastructure to build and deploy the changes.</p>
<p>Note that the <code>openshift</code> profile in pom.xml is activated by OpenShift, and causes the WAR build by OpenShift to be copied to the deployments/ directory, and deployed without a context path.</p>
<p>Now you can see the application running at <a href="http://APP_NAME-YOUR_DOMAIN.rhcloud.com/">http://APP_NAME-YOUR_DOMAIN.rhcloud.com/</a>.</p>
</body></html>