glassfish
  1. glassfish
  2. GLASSFISH-20800

NoSuchMethodException when attempting to install log handler in GlassFish server

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 3.1.2_b05, 4.0_b89_RC5
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      I am attempting to configure GF server to use SMTPHandler (http://smtphandler.sourceforge.net/), and get NoSuchMethodException on SMTPTransport during domain startup. This occurs without having any applications deployed to the server and only the minimal changes to configure this log handler for the domain.

      I can reproduct on both GF 3.1.2.2 and 4 (build 89). The only difference in testing these two is to either use JavaMail 1.4 (GF 3.1.2.2) or JavaMail 1.5 (GF 4).

      To reproduce, make the following change to domains/domain1/config/logging.properties:

      Old:
      handlers=java.util.logging.ConsoleHandler
      New:
      handlers=java.util.logging.ConsoleHandler,smtphandler.SMTPHandler

      Add:
      smtphandler.SMTPHandler.level=SEVERE
      smtphandler.SMTPHandler.smtpHost=<your SMTP server>
      smtphandler.SMTPHandler.to=<your email to: address>
      smtphandler.SMTPHandler.from=<your email from: address>
      smtphandler.SMTPHandler.subject=[SMTPHandler] Application message

      Then copy smtphandler-0.6.jar (attached) and mail.jar to domains/domain1/lib/ext directory. The version of the mail.jar to use is based on the version of GF you are using as noted above.

      Alternatively, you can update the META-INF/MANIFEST.MF in the smtphandler-0.6.jar to add the following so that it will use the same JavaMail JAR file (osgi bundle) that is deployed with GF.

      Class-Path: ../../../../modules/javax.mail.jar

      After making these changes, start the domain (asadmin start-domain) and you will see the errors below when SEVERE error is logged by GF server when it determines that the certificate installed is expired. Sometimes the first message will send fine, but then subsequent messages fail with the errors below.

      [2013-09-06T15:10:23.873-0400] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=16 _ThreadName=Thread-3] [timeMillis: 1378494623873] [levelValue: 800] [[
      DEBUG: setDebug: JavaMail version 1.5.0]]

      [2013-09-06T15:10:23.876-0400] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=16 _ThreadName=Thread-3] [timeMillis: 1378494623876] [levelValue: 800] [[
      DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]]]

      [2013-09-06T15:10:23.876-0400] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=16 _ThreadName=Thread-3] [timeMillis: 1378494623876] [levelValue: 800] [[
      DEBUG: Exception loading provider, THROW:]]

      [2013-09-06T15:10:23.850-0400] [glassfish 4.0] [SEVERE] [] [] [tid: _ThreadID=35 _ThreadName=Thread-4] [timeMillis: 1378494623850] [levelValue: 1000] [[
      java.util.logging.ErrorManager: 1: sendBuffer]]

      [2013-09-06T15:10:23.888-0400] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=16 _ThreadName=Thread-3] [timeMillis: 1378494623888] [levelValue: 800] [[
      java.lang.NoSuchMethodException: com.sun.mail.smtp.SMTPTransport.<init>(javax.mail.Session, javax.mail.URLName)
      at java.lang.Class.getConstructor0(Class.java:2730)
      at java.lang.Class.getConstructor(Class.java:1676)
      at javax.mail.Session.getService(Session.java:799)
      at javax.mail.Session.getTransport(Session.java:728)
      at javax.mail.Session.getTransport(Session.java:668)
      at javax.mail.Session.getTransport(Session.java:648)
      at javax.mail.Session.getTransport(Session.java:705)
      at javax.mail.Transport.send0(Transport.java:248)
      at javax.mail.Transport.send(Transport.java:124)
      at smtphandler.SMTPHandler.sendBuffer(SMTPHandler.java:355)
      at smtphandler.SMTPHandler.publish(SMTPHandler.java:185)
      at java.util.logging.Logger.log(Logger.java:565)
      at com.sun.common.util.logging.LoggingOutputStream.log(LoggingOutputStream.java:152)
      at com.sun.common.util.logging.LoggingOutputStream$1.run(LoggingOutputStream.java:125)]]

        Activity

        Hide
        Craig Brumfield added a comment - - edited

        Note, I also enabled verbose classpath logging for the domain so that I could verify that there were not extraneous versions of JavaMail, etc. classes being loaded, but did not see any that were obvious.

        Also, this issue has been reproduced on the Linux environment--not tested on Windows.

        Show
        Craig Brumfield added a comment - - edited Note, I also enabled verbose classpath logging for the domain so that I could verify that there were not extraneous versions of JavaMail, etc. classes being loaded, but did not see any that were obvious. Also, this issue has been reproduced on the Linux environment--not tested on Windows.
        Hide
        jmehrens added a comment -

        When working on the MailHandler I uncovered the root cause and proposed a patch for JavaMail. The JavaMail team issued the patch (https://java.net/projects/javamail/sources/mercurial/revision/680) and filed a JavaMail issue to track the changes as Bug 6668 -skip unusable Store and Transport classes (https://kenai.com/bugzilla/show_bug.cgi?id=6668). Using JavaMail 1.5.3 should fix the issue.

        The only other workaround is to set the context classloader to the classloader returned by javax.mail.Sesssion.class.getClassLoader() during the call to Transport.send.

        Show
        jmehrens added a comment - When working on the MailHandler I uncovered the root cause and proposed a patch for JavaMail. The JavaMail team issued the patch ( https://java.net/projects/javamail/sources/mercurial/revision/680 ) and filed a JavaMail issue to track the changes as Bug 6668 -skip unusable Store and Transport classes ( https://kenai.com/bugzilla/show_bug.cgi?id=6668 ). Using JavaMail 1.5.3 should fix the issue. The only other workaround is to set the context classloader to the classloader returned by javax.mail.Sesssion.class.getClassLoader() during the call to Transport.send.

          People

          • Assignee:
            michael.y.chen
            Reporter:
            Craig Brumfield
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: