Building and Deploying in Eclipse
Overview
Documents setting up code, config, and data in a development environment using Eclipse.
Prerequisites
Git client (i.e. Tortoise Git)
Java 8 installed
Mysql 6.3 installed
Maven 3.3.9. installed
Tomcat 8 installed and configured
Eclipse Oxygen - J2EE edition
Note that the below are likely deprecated (added in 2015) but leaving them here in case needed for reference
Use version 4.4 (Luna) - J2EE edition
m2e (the maven integration for eclipse - download from the market place)
m2e-egit connector
eGit - http://eclipse.github.com/
Jautodoc - import configuration from Code and XML Formatting in Eclipse
ObjectAid UML Diagram tool for class hierarchy visualization. Installed via Help->Install New Software. Instructions athttp://www.objectaid.net/installation
FindBugs (static code analysis)
AngularJS - see https://github.com/angelozerr/angularjs-eclipse/wiki/Getting-Started
Details
Step 1 - Create directories
Setup for Windows
Create a directory to hold your data files (e.g. c:/termserver/data)
Create a directory to hold your config files (e.g. c:/termserver/config)
Create a directory to hold the code (e.g. c:/workspace/SNOMED-Terminology-Server)
Make sure the "mvn" executable for your local maven installation is in the path
On Windows this means adding to the PATH variable so that it runs in a "cmd" shell without fully qualified path.
Setup for Unix/Linux/Mac
Create a directory to hold your data files (e.g. ~/data)
Create a directory to hold your config files (e.g. ~/config)
Create a directory to hold the code (e.g. ~/code)
Make sure the "mvn" executable for your local maven installation is in the path
Step 2 - Clone repository
Clone the Github repository to the directory created to hold the code.
Step 3 - Build project
Build all project modules with "mvn clean install" at the top level - either through Eclipse or via the command line.
NOTE: this uses the standard "dev-windows" configuration. To use a different configuration artifact pass the following three parameters:
-Dconfig.groupId=...
-Dconfig.artifactId=...
-Dconfig.version=...
NOTE: the specified configuration artifact must either have been built locally or be an a repository accessible based on the settings.xml file
For most dev deployments, the default build is fine because the only setting really used for the rest/webapp packages is the "base.url" which by default is set to http://localhost:8080/umls-server-rest/
For a production deployment, you would want to use a different setting. For example, see Deploy Instructions for the prod deployment instructions.
Step 4 - Setup Configuration
Choose a "dev-windows" or "prod" config project target and unzip it into the directory created to hold your config files.
config/dev-windows/target/term-server-config-dev-windows.*.zip
config/prod/target/term-server-config-prod.*.zip
Unzip the config/target/term-server-config.*.zip file into the directory created to hold your data files (these are the sample SNOMED and ICD9CM data artifacts).
Step 5 - Edit configuration
Edit the "config.properties" file in your config files directory to set correctly for your environment. In particular, edit these:
javax.persistence.jdbc.url
javax.persistence.jdbc.user
javax.persistence.jdbc.password
hibernate.search.default.indexBase ( recommend choosing something in your data dir, e.g. c:/termesrver/data/indexes or ~/indexes)
mail.smtp.to (list for automated system emails)
Step 6 - Create database
Create a MySQL UTF8 database. e.g.
CREATE database tsdb CHARACTER SET utf8 default collate utf8_unicode_ci;
Step 7 - Load data
Run the admin loader script for your platform. In your config/bin directory there will be a handy loader script that sets up a basic dev environment based on the data provided in the config project.
Edit the file to set the SERVER_CODE, SERVER_CONFIG, and SERVER_DATA properties
Run appropriate script for your platform (only one will be available, depending on the configuration settings you unpacked in Step 4).
load.bat - for Windows
load.sh - for Unix/Linux/Mac
NOTE: if re-running this, you first have to run the sql in "truncate_all.sql" to clear your database of tables.
Step 8 - Deploy application
Deploy the term-server-rest.war file to a Tomcat server - either through Eclipse or a standalone tomcat installation.
Setting up Tomcat in Eclipse is very easy, you follow these steps.
Download and install apache tomcat 7 in c:/apache-tomcat-XXXX
In Eclipse use the J2EE perspective and click on the "Servers" tab.
From here, you can add a server which simply involves pointing Eclipse to the install directory for Tomcat.
You can right-click on term-server-rest.war file and use "Run As->Run on Server" to deploy to Tomcat.
NOTE: sometimes in Eclipse this doesn't work and the tomcat does not properly recognize or deploy the app.
In this event, double-click on the tomcat server installation in the servers tab.
In the configuration screen click "Open launch configuration"
There, look on the Arguments tab and find the -D setting for "catalina.base", e.g.
-Dcatalina.base="C:\Users\Brian Carlsen\workspace-luna\.metadata\.plugins\org.eclipse.wst.server.core\tmp0"If you open this directory you'll see a "webapps" folder. To deploy you simply build and copy term-server-rest.war to that directory and launch the server in Eclipse.
The Tomcat server needs to be able to find the run configuration. Double-click on the Tomcat server you installed, open the launch configuration and add this setting:
-Drun.config.ts=/path/to/your/config.properties
Step 9 - Test application
Check that it all works by going to
http://localhost:8080/term-server-rest/index.html
This should be a demo app that links to a "swagger" Api documenting the current state of the server. You should be able to test services by authenticating with "guest" username and "guest" password..
Step 10 - Integration test
Run the integration tests (only do this if you know what you're doing):
# configured to ponit ot DB loaded above.
mvn -Prest -DskipTests=false -Drun.config.ts=/path/to/config.properties
# configured to point to empty db
mvn -Pmojo -DskipTests=false -Drun.config.ts=/path/to/config-test.properties
References/Links