1. Glassfish Tools for Eclipse
In order to set up Glassfish to work with Maven and the Eclipse WTP you must first install the Glassfish Tools for Eclipse provided by Oracle.
First go the the Help > Eclipse Marketplace menu item and search for "glassfish". Click on the Glassfish Tools for Indigo option and install. Once finished, Eclipse will prompt you to restart.
Once Eclipse starts up again select the File > New menu item and select Server from the list in the dialog. From the server type list select GlassFish 3.1.2 and leave the host name as
You can either use a server that is already installed on your local machine (should be in
/usr/share/glassfish3/glassfish/) or create a new one just for the purposes of testing/debugging Eclipse projects (recommended approach). Specify the path of the existing server or enter a new path (i.e.
/home/lowery/servers) and click Install Server to install Glassfish to that location.
Once finished click Next. Type in the admin password on the next dialog before clicking Next to finish setting up the server.
If you installed Glassfish alongside another instance stop the other instance now to avoid port conflicts.
If you have Tomcat installed and running on port
8080 you must edit the Glassfish ports in directory you installed to in Eclipse, for example:
Open this file and change port
8081 wherever it is listed
2. Maven m2e and Eclipse WTP Integration
In order for the Maven m2e Eclipse plugin to work well with the WTP for deployment to a server you must install the m2e-wtp additions in Eclipse.
Go to the Help > Install New Software menu option and add the m2e-wtp update site:
http://download.eclipse.org/m2e-wtp/releases/juno/ and select
Maven Integration for WTP from the list. If you need to update your m2e plugin select
Maven Integration for Eclipse as well and install.
Right click on the FP-EAR project in the project explorer and click the Properties item in the context menu. On the dialog that appears select Project Facets on the left. Select the EAR list item (leave it checked, just select the entry) and click the Runtimes tab on the right. To add the new server to the project check the GlassFish 3.1.2 runtime and click ok.
In the Eclipse workspace open the Servers tab and double click on GlassFish 3.1.2 at localhost or right click it and click Properties to view the server properties editor in Eclipse.
NOTE: If you do not see the server tab on the bottom of your workspace you may need to switch to the JavaEE perspective by clicking Window > Open Perspective > Other and selecting JavaEE from the list.
Under the Application Server section at the very bottom of the properties now displayed in the editor, check the
"User" Real Jar Archives option and save the configuration.
Before we deploy we must make sure the server is configured properly. Refer to the deployment documentation for more details on how to configure Glassfish for FP-Medium. This is the same configuration you will need for testing and debugging.
Start by copying
mysql-connector-java-5.1.22-bin.jar (located in
/usr/share/glassfish3/glassfish/domains/domain1/lib/mysql-connector-java-5.1.22-bin.jar if you already have a configured instance of Glassfish installed) to the
domains/domain1/lib directory of the debugging server.
If you need to download the MySql J-Connector you may do so from the following location:
Restart the server from the Servers tab in Eclipse by right clicking GlassFish 3.1.2 at localhost and clicking Restart
Now you can use the admin control panel via http://localhost:4848 in the browser the same way you would if you were deploying normally. Add the required resources now (the connection pools named
mysql_fpannotationprocessor as well as the jdbc resources named
jdbc/mysql_fpannotationprocessor). See the deployment instruction mentioned earlier for details on how to do this.
4. Running and Debugging FP-EAR
Once you have configured the server you can deploy and run the application from Eclipse by right clicking the FP-EAR project in the Project Explorer and selecting Run As > Run on Server.
You can also use the Debug As option instead by selecting Debug As > Debug on Server. If you switch from run to debug mode you may need to restart Glassfish from within Eclipse via the Servers tab as before.
Now, whenever you make changes to any of the FP Modules, if you right click on the FP-JavaSOA project and select Run As > Maven Install the latest copy of the EAR will be deployed automatically if Glassfish is running. With FP-EAR deployed, view the main page of the Annotation Processor in a browser with breakpoints set anywhere in the Filteredpush code to start debugging:
NOTE: If you encounter the
org.hibernate.exception.GenericJDBCException: No database selected exception in the Annotation Processor make sure that your jdbc connection pool in Glassfish is configured properly (the Url and URL properties must include the database name