Build and run FP in Eclipse

From Filtered Push Wiki
Jump to: navigation, search

Warning icon.svgThis page is obsolete. Watch here for a link to more suitable page.

Prerequisites

The sections below have instructions on getting the deployment environment ready for deployment of Morphbank, FP-ClientHelper, and FP-Node.

Tomcat, Apache + PHP + PEAR

Install Tomcat 7, Apache 2.2.22 (must also have MySQL and JDK 1.6+) I left the default port configuration for Apache and Tomcat. The servers should be up and running at:

http://localhost

http://localhost:8080

Next you need to install PHP and PEAR with Apache. In Ubuntu I did this from synaptic (php5, php-pear, libapache2-mod-php5).

On Windows I used the msi installer for PHP 5.2 (Thread Safe) from the php website. Select the Apache 2.2.x Module on the "Web Server Setup" screen and when prompted, enter the apache conf directory (C:\Program Files\Apache Software Foundation\Apache2.2\conf). When the PHP installer gets to the point where you may "Choose Items to Install" select MySQL and MySQLI from Extensions and PEAR Install from Extras.

After the install, edit the C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf file. The installer should have added some configuration at the end of the file, change it to point to the correct directories like:

PHPIniDir "C:\Program Files\PHP"
LoadModule php5_module "C:\Program Files\PHP\php5apache2_2.dll"

See the following tutorial for the remaining steps (starting with 5.1): http://www.reaper-x.com/2007/09/24/installing-and-setting-up-apache-22-series-with-php-5-on-windows/

To finish the installation of PEAR on Windows, in the php directory run go-pear.bat to install. When it asks for system wide or local I selected system and pressed enter for the next prompt to accept all the locations. The last part will alter your php.ini file and set up the environment variables.

Installing PEARS

Now you can use "pear install" from the command line to install the PEAR's required by morphbank: http://sourceforge.net/apps/mediawiki/biodivimage/index.php?title=Biodiversity_Image_Repository#Required_PEAR_Packages

NOTE: You can use command "pear list" to view currently installed pears.

Set up Glassfish and Tomcat with Eclipse

For the next part, I used Eclipse Indigo JavaEE. To install Glassfish with Eclipse go to the Help Menu and select Eclipse Marketplace. Search for Glassfish and install the "GlassFish Java EE Application Server Plugin for Eclipse".

After installing, restart Eclipse and go to File > New > Other > Server select Server and click next. Under GlassFish select "GlassFish Server Open Source Edition 3 (Java EE 6) and type in the directory where you would like GlassFish installed and click finish.

Now create another server in Eclipse (File > New > Other > Server select Server and click next) This time, under Apache, select Tomcat v7.0 Server and browse to the location you installed Tomcat to previously. Tomcat7 and Glassfish should now be visible in the Servers view (Windows > Show View > Servers).

Start the server from Eclipse and go to the admin control console at the following url http://localhost:4848 (make sure Tomcat or any other server at 8080 is not running otherwise you will receive an error). Once the admin console is loaded, on the left go to Configuration > Network Config > http-listener-1. Change the port from 8080 to 8088 and save.

Maven m2e Eclipse Plugin

Once you have Morphbank running as well as Tomcat and Glassfish installed and configured with Eclipse the last prerequisite is to get the Maven plugin for Eclipse. Use the following update site with Help > Install New Software to install the plugin: http://download.eclipse.org/technology/m2e/releases.

Morphbank

After installing morphbank according to the instructions below, apply the patch for the annotation generation changes.

I followed Maureen's instructions (which link to the instructions on the morphbank sourceforge wiki as well http://etaxonomy.org/mw/Installing_Morphbank). If there are problems with running the install.php or importing the sample data you can try editing your my.cnf file and adding the line "thread_stack=1M". This fixed the issue for me, but I'm not sure why.

For now it is not necessary to install the Java Services in Tomcat, we can still use morphbank without them.

Also, Maureen's instructions add entries for morphbank to hosts, on Windows I made the same changes to C:\Windows\System32\Drivers\Etc\hosts. In order to set up virtual hosts I added the following to my httpd.conf instead of sites-availible and sites-enabled used on linux:

NameVirtualHost 127.0.0.1:80

<VirtualHost 127.0.0.1:80>
  ServerName morphbank-t
  DocumentRoot "C:/mb32/biodivimage/mb32/www"

  <Directory "C:/mb32/biodivimage/mb32/www">
    AllowOverride All
  </Directory>
</VirtualHost>

<VirtualHost 127.0.0.1:80>
  ServerName mb-images-t
  DocumentRoot C:/mb32/biodivimage/mb32/www/ImageServer

  <Directory C:/mb32/biodivimage/mb32/www/ImageServer>
    AllowOverride All
  </Directory>
</VirtualHost>

I also removed the following from the config (on Windows) so that I could access the directories defined in the two virtual hosts from a browser:

<Directory />
   Options FollowSymLinks
   AllowOverride None
   Order deny,allow
   Deny from all
</Directory>


FP-ClientHelper

Checkout the FP-ClientHelper project and the FP-AnnotationWS from the sourceforge svn.

svn co https://filteredpush.svn.sourceforge.net/svnroot/filteredpush/FP-ClientHelper/trunk
svn co https://filteredpush.svn.sourceforge.net/svnroot/filteredpush/FP-Deployments/FP-AnnotationWS/trunk

Be sure to configure the project Runtime Target for the Tomcat server on the FP-AnnotationWS project (right click on the project > Properties > Runtime Targets). Now you can deploy the project to Tomcat by right clicking > Run As > Run on Server. The service endpoint can be found at http://localhost:8080/AnnotationGen/generate. Next we will build and deploy the FP-Node project.

FP-Node

Checkout the following projects from the sourceforge svn.

svn co https://filteredpush.svn.sourceforge.net/svnroot/filteredpush/FP-API-Library/trunk
svn co https://filteredpush.svn.sourceforge.net/svnroot/filteredpush/FP-Deployments/FP-EAR
svn co https://filteredpush.svn.sourceforge.net/svnroot/filteredpush/FP-Node/trunk
svn co https://filteredpush.svn.sourceforge.net/svnroot/filteredpush/FP-Messaging/FP-Messaging-KVP/trunk


Configure Eclipse Project

An fp node deployment contains the following projects:

FP-API-Library - the api libraries used by the rest of the deployed components. FP-EAR - the ear deployment project to be deployed to the glassfish server FP-Node - contains the fp access point web service and related ejbs for the network node. FP-Messaging-KVP - contains the messaging EJBs

In Eclipse import these projects by selecting File > Import > Maven > Existing Maven Projects.

Once all projects have been imported, right click on one of them and select Maven > Update Project Configuration. Once this has finished right click on the project again and select Maven > Update Dependencies. Repeat the process for all projects.

You may have to resolve classpath issues such as the targeted runtime (which should be glassfish) and the jdk (which should be 1.6+). To do this, right click on a project and select Properties. You can fix targeted runtime issues in "Targeted Runtimes" and jdk issues in "Java Build Path". You can also try a clean via the Project menu on all the projects.


Messagestore DB

Create a database called messagestore in mysql and load in the messagestore.sql script which can be found in the FP-Messaging-KVP project directory root.


Configure Glassfish and Deploy

Once all classpath issues have been resolved we can configure GlassFish to prepare for the deployment. Start GlassFish from the Servers view in Eclipse and go to http://localhost:4848 in your browser for the admin console.

Set up the MySQL connector jar by downloading it from the mysql website and following instructions here: http://dev.mysql.com/doc/refman/5.0/en/connector-j-usagenotes-glassfish-config.html.

On the left select Resources > JDBC > Connection Pools and create a new connection pool named "mysql_messagestore" with the resource set as java.sql.ConnectionPoolDataSource and MySql selected as the vendor. In step two, you should configure the Password, DatabaseName (messagestore) and User properties at a minimum. Also, append the database name to the URL property (like jdbc:mysql://:3306/messagestore). Once you have done this click the finish button. Select the connection pool again from the list and edit it. On the edit page click the ping button to test your configuration.

Now on the left select Resources > JDBC > JDBC Resources and create a new resource "jdbc/__mysql_messagestore" with the connection pool you just created.

Note: if you end up using a different name for your connection pool you must edit the persistence.xml file in the META-INF directory in src/main/java of the FP_Messaging project.

With everything configured we can now deploy the ear to the server. In Eclipse, right click the FP_EAR project > Run As > Run on Server. Once the deployment is finished, go back to the home page of the GlassFish console, click List Deployed Applications, select FP_EAR and confirm that you are able to "View Endpoint" for the FPNetworkAccessPointWebService. With all the components deployed we can try out an annotation from Morphbank.

Annotation

Do the following with GlassFish and Tomcat running from Eclipse:

Go to http://morphbank-t/ login with the username and password you installed it with and go to Browse > Images. On the images page, pick an image and click on the small icon that looks like a pen writing in a book to create a new annotation. Select "Determination" from the type of annotation and fill in the info to submit it. Alternatively you can use Browse > Annotation and search for a determination. Click the small edit icon and resubmit the annotation form as an edit.