Arena PUJ - Development Environment Configuration
- 1 Where is the project specification?
- 2 QuickStart - The code up and running in ~10 minutes
- 2.1 Environment Setup
- 2.2 Adding permissions to Reflection based frameworks
- 2.3 Adding the permissions to Reflection based frameworks
- 2.4 Install MySql driver in Glassfish
- 2.5 Checkout and build the source code
- 2.6 Start the MySql database
- 2.7 Building and deploying the application
- 2.8 Testing the application
- 3 Quality assurance
- 4 References
- 4.1 HTTP Protocol
- 4.2 RESTful Web-Services
- 4.3 Java EE
- 4.4 Tools
Where is the project specification?
Would you like to know more about the project before to put your hands in the code jar? Here are the docs:
- The PUJ Competition (the business case).
- The Arena Project Specification.
QuickStart - The code up and running in ~10 minutes
The following instructions were tested in Linux Ubuntu 9.10, but we assume it will work in other operational systems as well. If you have questions or problems during your local setup, please feel free to send an email to fgaucho@gmail.com
Environment Setup
- Check if you have all software you need:
- Java 6.x
- Maven 2.x
- MySql 5.x
- Mercurial (if you are under some proxy try the mercurial 1.3.1 or newer)
- Glassfish v3 (glassfish b69 at least)
- Put the $GLASSFISH_HOME/bin in your $PATH (%path% on windows). It is required by the Maven script;
- Create a file called $HOME/.passwords directory, containing the following properties:
ASADMIN_USER=admin MAIL_HOST=smtp.some email.com MAIL_USER=user MAIL_FROM=user@somemail.com MAIL_SMTP_USER=user@somemail.com MAIL_SMTP_PORT=465 MAIL_SMTP_PASSWORD=some_password MYSQL_USER=root MYSQL_PASSWORD=adminadmin DB_URL=jdbc\\:mysql\\://localhost\\:3306/arena
- If you are using Windows, create the file %USERPROFILE%\.passwords and copy the above properties, but please change the DB_URL to:
DB_URL=jdbc\:mysql\://localhost\:3306/arena
Adding permissions to Reflection based frameworks
Adding the permissions to Reflection based frameworks
Add the below lines to the file $AS_HOME/domains/domain1/config/server.policy
grant codeBase "file:${com.sun.aas.installRoot}/domains/domain1/applications/arena-dwr/-" {
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
};
grant codeBase "file:${com.sun.aas.installRoot}/domains/domain1/applications/arena-vaadin/-" {
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
};
Install MySql driver in Glassfish
You need to copy the MySql Connector/J jar file to the folder $AS_HOME/domains/domain1/lib/ext
This should be done manually and you should restart the server after copying the file. more...
- Please check if you are using the default domain1, otherwise modify the above command according your Server domain name.
Checkout and build the source code
hg clone https://kenai.com/hg/puj~arena cd puj~arena mvn clean install eclipse:eclipse
Done! Now you can import the project in your preferred IDE and play around the source code.
Start the MySql database
If the MySql database is not yet running, please turn it on:
- Linux Users: /etc/rc.d/init.d/mysqld start
- Windows Users: C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld
Building and deploying the application
- Linux Users: use the profile -Phudson:
cd puj~arena asadmin start-domain mvn clean install -Phudson
- Windows Users: use the profile -PhudsonWin:
cd puj~arena asadmin start-domain mvn clean install -PhudsonWin
Testing the application
If everything worked fine, you should be able to access the following URLs:
Quality assurance
Java Quality Assurance & Continuous integration
Our project has a Continuous Integration Server configured to check the quality of our work continuously. If there is any commit in the last hour, this server will build a clean copy of the source code and generates quality reports based on Findbugs and PMD. Please visit that server regularly to check if your code is sound and considered good quality.
Also, please be sure to have the following plugins installed in your preferred IDE:
Encoding
Always use UTF-8 as the file encoding. If you will include HTML code in Java files, or other resources that will generate HTML output, please convert special characters to HTML encoding.
Image Shrinking
A good tool to compress images without loosing quality is the Yahoo Smush.it. Apply that to static images. Other hint about images is to always prefer PNG or JPG formats.
Web Resources Quality Assurance
If you are producing a web-application, please install YSlow in the browser you use to validate the quality of your code. And other good practice is to do a functional test of your web-gui against the major browsers on the market (at least Firefox, IExplorer and Chrome). There are some online services to test a web application on different machine configurations and browser versions, like the popular browsershots.org.
- YSlow
- browsershots.org (or Litmus, or thumbalizr)
Web resources validation: a good quality indicator about our web resources are the W3C validations. Please apply your documents for validation and review the W3C warnings and recommendations before to commit the files:
Other good tools for cleanup & enhance the quality of your web resources are:
- CSS Redundancy Checker
- CSSTidy
- JSLint (javascript validator)
- Web Page Analyzer
References
HTTP Protocol
- Caching Tutorial for Web Authors and Webmasters
- Atom Syndication Format
- Getting to know the Atom Publishing Protocol
RESTful Web-Services
- How to GET a Cup of Coffee
- PUT or POST: The REST of the Story
- Common REST Mistakes
- Building Web Services the REST Way










