ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzatz_5.4.0.1/51/program/jmldebug.htm

103 lines
6.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK rel="stylesheet" type="text/css" href="../../../rzahg/ic.css">
<title>Debug JavaMail</title>
</head>
<BODY>
<!-- Java sync-link -->
<SCRIPT LANGUAGE="Javascript" SRC="../../../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
<h4><a name="jmldebug"></a>Debug JavaMail</h4>
<p>At times, you may need to debug a JavaMail application. WebSphere Application Server - Express gives you the option to turn on the JavaMail debugging feature. Using this option, the JavaMail API prints interactions with the mail servers and the properties of the mail session to the Java virtual machine system out log file for your application server.</p>
<p>The mail debug feature is enabled on a per session basis. Perform these steps to enable the JavaMail debugging feature:</p>
<ol>
<li>Open the WebSphere Application Server administrative console. For more information, see <a href="../admin/acstart.htm">Start the WebSphere administrative console</a> in the <em>Administration</em> topic.</li>
<li>In the topology tree, expand <strong>Resources</strong>, and click <strong>Mail Providers</strong>.</li>
<li>Click the mail session you want to work with.</li>
<li>Click <strong>Mail Session</strong>, and click the mail session you want to work with.</li>
<li>Click <strong>Debug</strong>. Debug is enabled only for this session.</li>
<li>Click <strong>Apply</strong> or <strong>OK</strong>.</li>
<li>Click <strong>Save</strong> in the toolbar to save changes to the configuration.</li>
</ol>
<p>Once you have enabled debugging for JavaMail, the JavaMail APIs log the interactions between JavaMail applications and the e-mail server to the SystemOut Java virtual machine log file for the application server. See the <em><a href="../trb/trbjvmintro.htm">JVM log files</a></em> topic for more information on configuring and viewing JVM log files.</p>
<p>A sample of the JavaMail debugging output is as follows:</p>
<pre>
DEBUG: not loading system providers in &lt;java.home&gt;/lib
DEBUG not loading optional custom providers file: /META-INF/javamail.providers
DEBUG: successfully loaded default providers
DEBUG Tables of loaded providers
DEBUG: Providers listed by Class Name:
{com.sun.mail.smtp.SMTPTransport=javax.mail.Provider
[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider
[STORE,imap,com.sun.mail.imap.IMAPStore,Sun
Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider
[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun
Microsystems, Inc]}
DEBUG: Providers Listed By Protocol:
{imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems,
Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun
Microsystems, Inc], smtp=javax.mail.Provider
[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
Microsystems, Inc]}
DEBUG: not loading optional address map file: /META-INF/javamail.address.map
*** In SessionFactory.getObjectInstance,
The default SessionAuthenticator is based on:
store_user = john_smith
store_pw = abcdef
*** In SessionFactory.getObjectInstance, parameters in the new session:
mail.store.protocol="imap"
mail.transport.protocol="smtp"
mail.imap.user="john_smith"
mail.smtp.host="smtp.coldmail.com"
mail.debug="true"
ws.store.password="abcdef"
mail.from="john_smith@coldmail.com"
mail.smtp.class="com.sun.mail.smtp.SMTPTransport"
mail.imap.class="com.sun.mail.imap.IMAPStore"
mail.imap.host="coldmail.com"
DEBUG: mail.smtp.class property exists and points to com.sun.mail.smtp.SMTPTransport
DEBUG SMTP: useEhlo true, useAuth false
DEBUG: SMTPTransport trying to connect to host "smtp.coldmail.com", port 25
javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: Unknown SMTP host: smtp.coldmail.com;
nested exception is
java.net.UnknownHostException: smtp.coldmail.com
at javax.mail.Transport.send0(Transport.java:219)
at javax.mail.Transport.send(Transport.java:81)
at ws.mailfvt.SendSaveTestCore.runAll(SendSaveTestCore.java:48)
at testers.AnyTester.main(AnyTester.java:130)
</pre>
<p>This sample output illustrates a connection failure to a Simple Mail Transfer Protocol (SMTP) server because a fictitious name, smtp.coldmail.com, is specified as the server name.</p>
<p>The following are tips on how to read the debugging output:</p>
<ul>
<li>The lines headed by DEBUG are printed by the JavaMail run-time, while the two lines headed by *** are printed by the WebSphere Application Server - Express environment run-time.</li>
<li>The first two lines say that some configuration files are skipped. At run-time the JavaMail API attempts to load a number of configuration files from different locations. All those files are not required. If a required file cannot be accessed, the JavaMail API throws an exception. In this sample, there is no exception and the third line announces that default providers are loaded.</li>
<li>The next few lines, headed by either Providers listed by Class Name or Providers Listed by Protocols, show the protocol providers loaded. The three providers listed here are the default protocol providers that come under the WebSphere Application Server - Express built-in mail provider, for protocols SMTP, IMAP, and POP3, respectively. If you have installed special protocol providers (or, in JavaMail terminology, service providers) and these providers are used in the current mail session, you should see them listed here with the default providers. If you do not see the special protocol providers, there is a problem.</li>
<li>The two lines headed by *** and the few lines below them are printed by the WebSphere Application Server - Express environment to show the properties used to configure the current mail session. Although these properties are listed by their internal name rather than that used in the administrative console interface, it is not difficult to establish the similarities between them. For example, the property mail.store.protocol corresponds to the Protocol Name property in the Store Access section of the mail session configuration page. Make sure to review the listed properties and values to make sure they correspond.</li>
<li>The few lines above the exception stack show the JavaMail activities when sending a message. First, the JavaMail API recognizes the transport protocol is set to SMTP and the provider com.sun.mail.smtp.SMTPTransport exists. Next, the parameters used by SMTP, useEhlo and useAuth, are shown. Finally, the log shows the SMTP provider trying to connect to the mail server smtp.coldmail.com. Listed next is the exception stack. By now it should occur to us that the specified mail server either does not exist or is not functioning.</li>
</ul>
</body>
</html>