Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-13593

avoid “expected resource not found” warnings when using camel-mail in OSGi

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.23.3, 2.22.5, 2.24.1, 3.0.0, 2.25.0
    • Component/s: None
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      In javax.mail API(1.6), it(javax.mail.Session) will use authenticator's classloader to load two default files

      META-INF/javamail.default.address.map
      META-INF/javamail.default.providers
      

      Since camel-mail provider a DefaultAuthenticator, which means javax mail api will try to use camel-mail bundle classloader in OSGi to load above default files. Those files aren't available for camel-mail bundle classloader, so we see warning message as

       2019-04-25 12:42:09,806 | WARN | 23 - scheduler://foo | j.mail | 21 - com.sun.mail.javax.mail - 1.6.1 | expected resource not found: /META-INF/javamail.default.providers
      2019-04-25 12:42:09,807 | WARN | 23 - scheduler://foo | j.mail | 21 - com.sun.mail.javax.mail - 1.6.1| expected resource not found: /META-INF/javamail.default.address.map
      

      This warning message isn't harmful but annoying. The javax.mail.Session will always add default stuff by code if can't find the default configuration file

             if (providers.size() == 0) {
                  logger.config("failed to load any providers, using defaults");
                  // failed to load any providers, initialize with our defaults
                  addProvider(new Provider(Provider.Type.STORE,
                              "imap", "com.sun.mail.imap.IMAPStore",
                              "Oracle", Version.version));
                  addProvider(new Provider(Provider.Type.STORE,
                              "imaps", "com.sun.mail.imap.IMAPSSLStore",
                              "Oracle", Version.version));
                  addProvider(new Provider(Provider.Type.STORE,
                              "pop3", "com.sun.mail.pop3.POP3Store",
                              "Oracle", Version.version));
                  addProvider(new Provider(Provider.Type.STORE,
                              "pop3s", "com.sun.mail.pop3.POP3SSLStore",
                              "Oracle", Version.version));
                  addProvider(new Provider(Provider.Type.TRANSPORT,
                              "smtp", "com.sun.mail.smtp.SMTPTransport",
                              "Oracle", Version.version));
                  addProvider(new Provider(Provider.Type.TRANSPORT,
                              "smtps", "com.sun.mail.smtp.SMTPSSLTransport",
                              "Oracle", Version.version));
              }
             if (addressMap.isEmpty()) {
                  logger.config("failed to load address map, using defaults");
                  addressMap.put("rfc822", "smtp");
              }
      

      But it's better we can avoid such WARN message when using camel-mail in OSGi

        Attachments

          Activity

            People

            • Assignee:
              ffang Freeman Yue Fang
              Reporter:
              ffang Freeman Yue Fang
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: