Running the mailconnector Example
You can use either NetBeans IDE or Ant to build, package, deploy, and run the mailconnector example.
Before You Deploy the mailconnector Example
Before you deploy the mailconnector application, perform the following steps.
- Download mock-javamail-1.9.jar from http://download.java.net/maven/2/org/jvnet/mock-javamail/mock-javamail/1.9/.
- Copy this JAR file to the directory as-install/lib.
- Restart GlassFish Server.
- Open the GlassFish Server Administration Console in a web browser at http://localhost:4848.
- In the Administration Console, expand the Configurations node, then expand the server-config node.
- Select the Security node.
- Select the Default Principal to Role Mapping Enabled check box.
- Click Save.
To Build, Package, and Deploy the mailconnector Example Using NetBeans IDE
- From the File menu, choose Open Project.
- In the Open Project dialog, navigate to:
tut-install/examples/connectors/mailconnector/
- Select the mailconnector-ra folder and click Open Project.
- In the Projects tab, right-click the mailconnector-ra project and select Build.
This command builds the resource adapter. It also places identical files named mailconnector.rar and mailconnector.jar in the mailconnector directory.
- In the Projects tab, right-click the mailconnector-ra project and select Deploy.
- From the File menu, choose Open Project.
- In the Open Project dialog, navigate to:
tut-install/examples/connectors/mailconnector/
- Select the mailconnector-ear folder.
- Select the Open Required Projects check box and click Open Project.
- In the Projects tab, right-click the mailconnector-ear project and select Build.
- In a terminal window, navigate to:
tut-install/examples/connectors/mailconnector/mailconnector-ear/
- Enter the following command to create the resources and users:
ant setup
- In NetBeans IDE, in the Projects tab, right-click the mailconnector-ear project and select Deploy.
To Build, Package, and Deploy the mailconnector Example Using Ant
- In a terminal window, go to:
tut-install/examples/connectors/mailconnector/mailconnector-ear/
- Enter the following command:
ant all
This command builds and deploys the mailconnector-ra RAR file, sets up users and resources, then builds and deploys the mailconnector-ear EAR file. It also places identical files named mailconnector.rar and mailconnector.jar in the mailconnector directory.
To Run the mailconnector Example
- In a web browser, navigate to the following URL:
http://localhost:8080/mailconnector-war/
- Log in with a user name of either user1, user2, user3, or
user4. The password is the same as the user name.
You can send messages and browse for the messages you sent. The messages you sent are available 30 seconds after you sent them.
For example, you can log in as user1 and send a message to user4, then log in as user4 and query for messages. In the form for browsing messages, verify that the fields are correct, then click Browse.
View the server log to follow the flow of the application. Most classes and methods specify logging information that makes the sequence of events easy to follow.
- Before you undeploy the application, in a terminal window, navigate to tut-install/examples/connectors/mailconnector/mailconnector-ear/ and
enter the following command to remove the resources and users:
ant takedown
You cannot undeploy the resource adapter until you run this command.
Next Steps
When you clean the application, you can also remove the mailconnector.rar and mailconnector.jar files from the mailconnector directory.
Remove the mock-javamail-1.9.jar file from the as-install/lib directory if you might run any other applications that use the JavaMail API (for example, The async Example Application).