The Java EE 5 Tutorial

Building, Deploying, and Running the sendremote Modules Using NetBeans IDE

    To package the modules using NetBeans IDE, perform these steps:

  1. In NetBeans IDE, choose Open Project from the File menu.

  2. In the Open Project dialog, navigate to tut-install/javaeetutorial5/examples/jms/sendremote/.

  3. Select the replybean folder.

  4. Select the Open as Main Project check box.

  5. Click Open Project.

  6. Right-click the replybean project and choose Build.

    This command creates a JAR file that contains the bean class file.

  7. Choose Open Project from the File menu.

  8. Select the multiclient folder.

  9. Select the Open as Main Project check box.

  10. Click Open Project.

  11. Right-click the multiclient project and choose Build.

    This command creates a JAR file that contains the client class file and a manifest file.

    To deploy the multiclient module on the local server, perform these steps:

  1. Right-click the multiclient project and choose Properties.

  2. Select Run from the Categories tree.

  3. From the Server list, select Sun Java System Application Server (the local server).

  4. Click OK.

  5. Right-click the multiclient project and choose Undeploy and Deploy.

    To deploy the replybean module on the local and remote servers, perform these steps:

  1. Right-click the replybean project and choose Properties.

  2. Select Run from the Categories tree.

  3. From the Server list, select Sun Java System Application Server(the local server).

  4. Click OK.

  5. Right-click the replybean project and choose Undeploy and Deploy.

  6. Right-click the replybean project again and choose Properties.

  7. Select Run from the Categories tree.

  8. From the Server list, select Sun Java System Application Server (1) (the remote server).

  9. Click OK.

  10. Right-click the replybean project and choose Undeploy and Deploy.

You can use the Services tab to verify that multiclient is deployed as an App Client Module on the local server and that replybean is deployed as an EJB Module on both servers.

To run the application client, right-click the multiclient project and choose Run.

This command returns a JAR file named multiclientClient.jar and then executes it.

On the local system, the output of the appclient command looks something like this:


running application client container.
Sent message: text: id=1 to local app server
Sent message: text: id=2 to remote app server
ReplyListener: Received message: id=1, text=ReplyMsgBean processed message: text: id=1 to local
 app server
Sent message: text: id=3 to local app server
ReplyListener: Received message: id=3, text=ReplyMsgBean processed message: text: id=3 to local
 app server
ReplyListener: Received message: id=2, text=ReplyMsgBean processed message: text: id=2 to remote
 app server
Sent message: text: id=4 to remote app server
ReplyListener: Received message: id=4, text=ReplyMsgBean processed message: text: id=4 to remote
 app server
Sent message: text: id=5 to local app server
ReplyListener: Received message: id=5, text=ReplyMsgBean processed message: text: id=5 to local
 app server
Sent message: text: id=6 to remote app server
ReplyListener: Received message: id=6, text=ReplyMsgBean processed message: text: id=6 to remote
 app server
Sent message: text: id=7 to local app server
ReplyListener: Received message: id=7, text=ReplyMsgBean processed message: text: id=7 to local
 app server
Sent message: text: id=8 to remote app server
ReplyListener: Received message: id=8, text=ReplyMsgBean processed message: text: id=8 to remote
 app server
Sent message: text: id=9 to local app server
ReplyListener: Received message: id=9, text=ReplyMsgBean processed message: text: id=9 to local
 app server
Sent message: text: id=10 to remote app server
ReplyListener: Received message: id=10, text=ReplyMsgBean processed message: text: id=10 to remote
 app server
Waiting for 0 message(s) from local app server
Waiting for 0 message(s) from remote app server
Finished
Closing connection 1
Closing connection 2

On the local system, where the message-driven bean receives the odd-numbered messages, the output in the server log looks like this (wrapped in logging information):


ReplyMsgBean: Received message: text: id=1 to local app server
ReplyMsgBean: Received message: text: id=3 to local app server
ReplyMsgBean: Received message: text: id=5 to local app server
ReplyMsgBean: Received message: text: id=7 to local app server
ReplyMsgBean: Received message: text: id=9 to local app server

On the remote system, where the bean receives the even-numbered messages, the output in the server log looks like this (wrapped in logging information):


ReplyMsgBean: Received message: text: id=2 to remote app server
ReplyMsgBean: Received message: text: id=4 to remote app server
ReplyMsgBean: Received message: text: id=6 to remote app server
ReplyMsgBean: Received message: text: id=8 to remote app server
ReplyMsgBean: Received message: text: id=10 to remote app server

    Undeploy the modules after you finish running the client. To undeploy the modules, perform these steps:

  1. Click the Services tab.

  2. Expand the Servers node.

  3. Expand the Sun Java System Application Server node (the local system).

  4. Expand the Applications node.

  5. Expand the EJB Modules node.

  6. Right-click replybean and choose Undeploy.

  7. Expand the App Client Modules node.

  8. Right-click multiclient and choose Undeploy.

  9. Expand the Sun Java System Application Server (1) node (the remote system).

  10. Expand the Applications node.

  11. Expand the EJB Modules node.

  12. Right-click replybean and choose Undeploy.

    To remove the generated files, follow these steps:

  1. Right-click the replybean project and choose Clean.

  2. Right-click the multiclient project and choose Clean.