aboutsummaryrefslogtreecommitdiffstats log msg author committer range
 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 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502   Installing and exploring @greenpages@ Installing @greenpages@
Obtaining @greenpages@ This document provides instructions for building the complete @greenpages@ application and running it in @webserv@ as well as running tests and executing it from the @sts@. In addition, the application is examined in development stages from @sts@, stepping through the development process and comparing this to the solution. To get the completed @greenpages@ application, including tests and explanatory skeleton parts: download the latest ZIP file from @greenpages.download.url@ extract all the files from the ZIP file to a convenient directory (preserving the directory structure). To extract the files on Windows: prompt> mkdir c:\springsource\samples prompt> cd c:\springsource\samples prompt> jar xf c:\path\to\@greenpages.zip.file@ prompt> set GREENPAGES_HOME=c:\springsource\samples\@greenpages.expanded.dir@ To extract the files on Unix systems: prompt$mkdir -p /opt/springsource/samples prompt$ cd /opt/springsource/samples prompt$unzip /path/to/@greenpages.zip.file@ prompt$ export GREENPAGES_HOME=/opt/springsource/samples/@greenpages.expanded.dir@ The environment variable GREENPAGES_HOME set here is not used by the projects, but is used as a shorthand in the instructions that follow. The @greenpages@ zip file contains two main directories called solution and start. The solution directory contains the completed application which can be built and tested (as described in the next section). The start directory contains an initial skeleton of the @greenpages@ application which can be used to generate the full application. The examination steps refer to this skeleton by way of illustration. To follow the examination steps read after installing the full application in the following section.
Building with @maven.full@ @greenpages@ uses @maven.full@ as its primary build system. Each module of the application can be built separately and the entire application can built and assembled into a PAR file from a single location. To build the application and assemble it into a PAR file: Make $GREENPAGES_HOME/solution the current directory. Run the command mvn package. The first time this is run several files will be downloaded from @maven@ repositories and @s2@ repositories. Subsequent runs will not need to do this. Verify that the greenpages-@app.version@.par file exists in$GREENPAGES_HOME/solution/greenpages/target.
Installing dependencies into @webserv@ Unlike traditional Java EE applications, @greenpages@ does not package all of its dependencies inside its deployment unit. Instead, it relies on the mechanisms of OSGi to locate its dependencies at runtime. When running an OSGi application on @webserv@, these dependencies can be loaded into memory as needed, but first they must be made available to @webserv@. The Maven build included with @greenpages@ uses the dependency:copy-dependencies plugin to gather all the artifacts that @greenpages@ depends on that are not supplied by the @webserv@ runtime. These dependencies can then be installed into the @webserv@ repository. Dependencies are gathered automatically during the package phase. These dependencies can be found in $GREENPAGES_HOME/solution/greenpages/target/par-provided. To install dependencies simply copy all the *.jar files from this directory into$VWS_HOME/repository/usr. Installing dependencies on Windows: prompt> cd %GREENPAGES_HOME%\solution\greenpages prompt> copy target\par-provided\* %VWS_HOME%\repository\usr Installing Dependencies on UNIX: prompt$cd$GREENPAGES_HOME/solution/greenpages prompt$cp target/par-provided/*$VWS_HOME/repository/usr Notice that @webserv@ will not necessarily see these dependencies unless its repository indexes are rebuilt. Different repositories behave differently in this respect; some are passive (their indexes are built only once upon startup) and some are active (they can detect new files or files being removed dynamically). The usr repository is active so there is no need to restart @webserv@ when copying these files. The next time @webserv@ is started the -clean option will cause @webserv@ to re-scan the repository directories in any case. It is always safe to start @webserv@ with the -clean option.
Starting and configuring the database @greenpages@ uses the H2 database to store all its data. Before starting the application, start the database server and populate the database with data. Change to the $GREENPAGES_HOME/db current directory. On Unix: prompt$ cd $GREENPAGES_HOME/db On Windows: prompt> cd %GREENPAGES_HOME%\db Run the database startup script appropriate to the operating system. For Unix, this is run.sh, run in the background: prompt$ sh run.sh & Press Return to continue. On Windows, run the run.bat command: prompt> run For both platforms, the command might invoke a browser window offering a connection to the database; close this window. Run the data population script appropriate to the operating system. For Unix, this is data.sh: prompt$sh data.sh On Windows, run the data.bat command: prompt> data Run these commands once to start a database server for H2; the server will continue to run in the background. Installing and starting @greenpages@ PAR To install the @greenpages@ PAR into @webserv@ and start it: Copy the @greenpages@ PAR to the$VWS_HOME/pickup directory. On Unix: prompt$cd$VWS_HOME prompt$cp$GREENPAGES_HOME/solution/greenpages/target/greenpages-solution-@app.version@.par pickup/ On Windows: prompt> cd %VWS_HOME% prompt> copy %GREENPAGES_HOME%\solution\greenpages\target\greenpages-solution-@app.version@.par pickup\ Start @webserv@ with the -clean option. On Unix: promptVWS_HOME/bin/startup.sh -clean On Windows: prompt> "%VWS_HOME%"\bin\startup.bat -clean Verify that @greenpages@ starts correctly by checking in the @webserv@ output for the log message: <DE0005I> Started par 'greenpages' version '@app.version@'.
Importing the @greenpages@ projects into Eclipse Before starting the @greenpages@ application from Eclipse, import the projects: Open the Import Wizard using FileImport. From the Import Wizard select GeneralExisting Projects into Workspace and click Next: Click Browse… and select $GREENPAGES_HOME/solution as the root directory. In the Import Projects window, select all the projects and click Finish: Validate that the imported projects appear in Package Explorer: There may be compilation errors at this stage. Configuring @webserv@ target runtime Projects for @webserv@ are associated with a @virgo@ @webserv@ runtime environment in Eclipse. This is to allow launching and testing from within Eclipse, and also to allow classpath construction in Eclipse to mirror the dynamic classpath in the @webserv@ runtime. Compilation errors in the previous step will be resolved here. To configure a @webserv@ runtime environment: Open WindowShow ViewOther…. In the Show View dialog choose ServerServers to make the servers view visible: Right-click in the Servers (which may not be empty) view and select NewServer. In the New Server dialog, choose EclipseRTVirgo Web Server and click Next. Click Browse and select the$VWS_HOME directory. Ensure that a JRE is selected supporting Java 1.6 or above. Click Finish to complete creation of the server: Select all projects (except Servers) in Package Explorer. Right-click on the projects and choose Close Project and then Open Project. It is possible that there remain spurious build errors from Eclipse (see the Problems view), in which case a project clean build may clear the problems. Select ProjectClean… from the main menu, and choose to Clean all projects. It may be necessary to repeat this on a few projects. (This process is sometimes known as the Eclipse dance.) Despite the dance steps outlined, there will remain some Warnings like this: It is safe to ignore these.
Running @greenpages@ from within Eclipse Now that @greenpages@ is successfully imported into Eclipse, run the project directly from within the IDE. If the @greenpages@ PAR file was copied to the pickup directory, be sure it is now removed so that it does not conflict with the deployment of the Eclipse project. On Unix: prompt$cd$VWS_HOME/pickup prompt\$ rm greenpages-solution-@app.version@.par On Windows: prompt> cd %VWS_HOME%\pickup prompt> del greenpages-solution-@app.version@.par Also, to prevent conflicts with the server configured in Eclipse, stop a currently-running @webserv@ by typing Control-C in the console window. To run @greenpages@ from within Eclipse: Right click on the @webserv@ instance in the Servers view and select the Add and Remove… menu item. Add greenpages-solution (which is the containing project or PAR) to the server and finish. To start @webserv@ from within Eclipse right-click on the @webserv@ node in the Servers window and choose Start. The Servers view should now show the server and the added project: Verify that @greenpages@ is started correctly by checking for <DE0005I> Started par 'greenpages' version '@greenpages.version.number@'. in the Console window. (If errors are shown implying that @greenpages@ failed to be installed, this may be because some dependencies were not copied to @webserv@, as described in section . Check this.) Once installed and started @greenpages@ is again available from a web browser at the address http://localhost:8080/greenpages.