4 Replies Latest reply on Oct 23, 2006 3:10 PM by bezdomny

    4.05GA javamail problem

    bezdomny

      I'm using a base install of 4.05GA and I get the following exception when trying to use javamail. I'm using the default service bound to java:/Mail.

      java.lang.NoClassDefFoundError: com/sun/mail/util/SharedByteArrayInputStream

      I get the mail session fine, but when I try to create a MimeMessage object like so:
      Message m = new MimeMessage(mailSession);

      //this also fails:
      MimeMessage m = new MimeMessage(mailSession);

      I get the exception. Any ideas?

      Thanks!!

      B

        • 1. Re: 4.05GA javamail problem
          dimitris

          Can you post the full stacktrace?

          • 2. Re: 4.05GA javamail problem
            bezdomny

            Hey Dimitris,
            I would if I could, but as soon as the MimeMessage(mailSession) constructor is called and InvocationTargetException is thrown, then I see the java.lang.NoClassDefFoundError: com/sun/mail/util/SharedByteArrayInputStream

            Here is my method:

            public void sendMessage() {

            try {
            Session mailSession = null;

            try {
            Context ctx = new InitialContext();
            Object objref = ctx.lookup("java:/Mail");
            mailSession = (Session) PortableRemoteObject.narrow(objref, Session.class);
            } catch (NamingException e) {

            System.out.println(e);
            e.printStackTrace();
            }

            MimeMessage msg = new MimeMessage(mailSession);

            msg.setSubject(subject);
            msg.setSentDate(new Date());
            msg.setFrom();
            msg.setRecipients(Message.RecipientType.TO, getAddresses());
            msg.setText(mailMessage);

            Transport.send(msg);

            }
            catch (MessagingException e) {
            logger.log(Level.SEVERE, "messaging error: ", e);
            }
            }

            Bob

            • 3. Re: 4.05GA javamail problem
              dimitris

              Do you happen to have any duplicate version of mail.jar in your deployment?

              • 4. Re: 4.05GA javamail problem
                bezdomny

                Yep That was it. I'm using a third party jar that has some of the old sun/* classes included. When I removed that, my problem was solved. Thanks for the help.

                B