javaeetutorial
  1. javaeetutorial
  2. JAVAEETUTORIAL-100

Async example doesn't always fail as described

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 6.0.7-3
    • Fix Version/s: 6.0.7-4
    • Component/s: doc
    • Labels:
      None

      Description

      At the end of the two sections on running the async example are the following sentences:

      "If an error occurs, the status will read Encountered an error. Check the server.log file for your domain to find the cause of the error."

      If a user happens to have run the mailconnector example before they run this example, and they still have the mock-javamail JAR file in their glassfish/lib directory, the status message they see will be "javax.ejb.EJBException", and the server log stack trace will contain

      SEVERE: Error in sending message.
      WARNING: EJB5184:A system exception occurred during an invocation on EJB MailerBean, method: public java.util.concurrent.Future async.ejb.MailerBean.sendMessage(java.lang.String)
      WARNING: javax.ejb.EJBException
      ...
      Caused by: java.lang.NullPointerException
      at async.ejb.MailerBean.sendMessage(MailerBean.java:63)

      I don't know if this belongs in the tutorial itself or in the FAQ – probably the latter?

        Activity

        Hide
        Ian Evans added a comment -

        Could you attach your server.log? I want to know why the EJBException was thrown.

        Does the mailconnector example also use mail/myExampleSession?

        Show
        Ian Evans added a comment - Could you attach your server.log? I want to know why the EJBException was thrown. Does the mailconnector example also use mail/myExampleSession?
        Hide
        Kim Haase added a comment -

        Here is the server log from today, when I just started GF, edited the glassfish-resources file in async/setup, deployed async, and tried to send a message, then undeployed and shut down GF.

        The javamail resource in mailconnector has a different name, mail/MySession.

        I guess you are trying to figure out how to detect this particular problem and generate a useful error message? That would be good, though it is an error that won't occur if people run the tutorial examples in book order. At a minimum we should document the need to move the mock-javamail jar out of glassfish/lib if it happens to be there.

        Show
        Kim Haase added a comment - Here is the server log from today, when I just started GF, edited the glassfish-resources file in async/setup, deployed async, and tried to send a message, then undeployed and shut down GF. The javamail resource in mailconnector has a different name, mail/MySession. I guess you are trying to figure out how to detect this particular problem and generate a useful error message? That would be good, though it is an error that won't occur if people run the tutorial examples in book order. At a minimum we should document the need to move the mock-javamail jar out of glassfish/lib if it happens to be there.
        Hide
        Ian Evans added a comment -

        I don't see a reason why the presence of mock-javamail.jar should cause an EJBException, I guess. I'd like to find out why. Documenting the workaround in the FAQ is probably the easy step, but if we can allow the different examples to co-exist that's preferable.

        Show
        Ian Evans added a comment - I don't see a reason why the presence of mock-javamail.jar should cause an EJBException, I guess. I'd like to find out why. Documenting the workaround in the FAQ is probably the easy step, but if we can allow the different examples to co-exist that's preferable.
        Hide
        Ian Evans added a comment -

        Ok, so mock-javamail.jar doesn't implement an SMPTS provider.
        SEVERE: Error in sending message.
        SEVERE: No provider for smtps

        The NPE was caused by how I was trying to log the exception. Just changing the catch to:
        } catch (MessagingException ex)

        { logger.severe("Error in sending message."); status = "Encountered an error: " + ex.getMessage(); logger.severe(ex.getMessage()); }

        Logs the error message properly and doesn't cause a system exception. I'll check in the changes, but we should add a FAQ entry documenting that you must remove mock-javamail.jar before running async.

        Show
        Ian Evans added a comment - Ok, so mock-javamail.jar doesn't implement an SMPTS provider. SEVERE: Error in sending message. SEVERE: No provider for smtps The NPE was caused by how I was trying to log the exception. Just changing the catch to: } catch (MessagingException ex) { logger.severe("Error in sending message."); status = "Encountered an error: " + ex.getMessage(); logger.severe(ex.getMessage()); } Logs the error message properly and doesn't cause a system exception. I'll check in the changes, but we should add a FAQ entry documenting that you must remove mock-javamail.jar before running async.
        Hide
        Ian Evans added a comment -

        Fixed the NPE when the message couldn't be sent. The FAQ needs to be updated to include information on removing mock-javamail.jar from glassfish/lib.

        Does the mailconnector example section need instructions on this as well?

        Show
        Ian Evans added a comment - Fixed the NPE when the message couldn't be sent. The FAQ needs to be updated to include information on removing mock-javamail.jar from glassfish/lib. Does the mailconnector example section need instructions on this as well?
        Hide
        Kim Haase added a comment -

        > Does the mailconnector example section need instructions on this as well?

        Yes, we should add something at the end about removing it and restarting GlassFish just in case. Shall I do it as part of this issue?

        Show
        Kim Haase added a comment - > Does the mailconnector example section need instructions on this as well? Yes, we should add something at the end about removing it and restarting GlassFish just in case. Shall I do it as part of this issue?
        Hide
        Ian Evans added a comment -

        Sure. Go ahead and reopen it and reassign.

        Show
        Ian Evans added a comment - Sure. Go ahead and reopen it and reassign.
        Hide
        Kim Haase added a comment -

        I went ahead and made the documentation fix for the connector example as part of this issue.

        Show
        Kim Haase added a comment - I went ahead and made the documentation fix for the connector example as part of this issue.
        Hide
        Kim Haase added a comment -

        Assigning to myself for doc fix.

        Show
        Kim Haase added a comment - Assigning to myself for doc fix.
        Hide
        Kim Haase added a comment -

        Made fix in Epic and Frame versions of connector example chapter.

        Show
        Kim Haase added a comment - Made fix in Epic and Frame versions of connector example chapter.

          People

          • Assignee:
            Kim Haase
            Reporter:
            Kim Haase
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: