This is part 4 of the Java Technologies Integration tutorial

Execution

The final part of your development is to execute our project and see fruits of our hard work. To run our project we have to build war file/directory and deploy it on Tomcat server.

War file/directory

Building war file/directory is always the same. In order to do it run the following commands:

mvn clean
mvn compile
mvn war:war

This combination ensures that previous compilations are cleaned and only the outcome of the newest compilation is placed in war file/directory. Keep in mind that ‘mvn war:war’ does not compile project sources. Final content of target as well as war directory is presented in Figure 13.

Final_content

Deployment to Tomcat server

There is a number of ways to deploy it to Tomcat server.

  • You can just copy content of target/IntegrationProject-1.0/ to webapps/IntegrationProject/ directory in Tomcat and start the server. Start Tomcat server.
  • You can make symlink webapps/IntegrationProject/ to point to target/IntegrationProject-1.0/. You should restart Tomcat when content of war file directory changes.
  • You can make symlink in WebContent to point to target/IntegrationProject-1.0/. Then add it to Tomcat server previously configured in Ecplise as shown in Figure 14. Start the server. After each project refresh if java classes changed the server will restart. If you did the change to xml files you might have to restart the server manually.

ecplise_tomcat_deployment

Final result

To see the final result go to ‘http://localhost:8080/IntegrationProject/listAllUsers.action’. This action should list all the users in the database and provide a link to add new one. Click on ‘Add’. This should invoke ‘http://localhost:8080/IntegrationProject/addUserForm.action’ as presented in Figure 15.

add_user_form

Fill in the form and click ‘Submit’. This should invoke ‘addUser.action’, which adds user to the database and redirect the request to listAllUsers.action as presented in Figure 16.

list_all_action

When you click delete the following action deleteUser.action with parameter id=id of user to be deleted will be issues and the user will be deleted from the database.

Updates to the project can be found in part 5 of the tutorial, which can be found here: Java Technologies Integration tutorial – part 5 – Hibernate update