4 Replies Latest reply on Oct 11, 2012 1:08 AM by rajendra85

    Problem with JBoss AS 7.0 Final + Java Mail + java.lang.NoClassDefFoundError: javax/net/ssl/SSLPeerUnverifiedException

    rajendra85

      Hi friends,

       

      As am using java mail api from JBoss 7.0 AS final in my application. Am trying to send a mail from mail server or localhost... But

       

      Im getting this error in my application . Can someone help me with this?

       

      java.lang.NoClassDefFoundError: javax/net/ssl/SSLPeerUnverifiedException

      com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1900)

      com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)

      javax.mail.Service.connect(Service.java:295)

      javax.mail.Service.connect(Service.java:176)

      javax.mail.Service.connect(Service.java:125)

      javax.mail.Transport.send0(Transport.java:194)

      javax.mail.Transport.send(Transport.java:124)

      com.vz.ag.util.UrlMailer.SendMail(UrlMailer.java:106)

      com.vz.ag.servlet.sso.VerifyServlet.activatePwreset(VerifyServlet.java:149)

      com.vz.ag.servlet.sso.VerifyServlet.processRequest(VerifyServlet.java:91)

      com.vz.ag.servlet.sso.VerifyServlet.doPost(VerifyServlet.java:49)

      javax.servlet.http.HttpServlet.service(HttpServlet.java:754)

      javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

       

       

      Can anybody please provide me correct or step by step configuration in JBoss 7.0.

       

      For me its an urgent requirement, am struggling with above error..

       

      As I checked modules/javax/mail/main/ I have javamail1.4.4.jar and module.xml are there..

       

       

      Thanks in advance

       

      Rajendra J

        • 1. Re: Problem with JBoss AS 7.0 Final + Java Mail + java.lang.NoClassDefFoundError: javax/net/ssl/SSLPeerUnverifiedException
          ctomc

          Hi,

           

          is possible I would ugre you to upgrade to 7.1.x which has mail subsystem and has many issues in this area fixed.

           

          if that is not option, please post your code that sends msg and contents of javax/mail/main/module.xml

           

           

          --

          tomaz

          • 2. Re: Problem with JBoss AS 7.0 Final + Java Mail + java.lang.NoClassDefFoundError: javax/net/ssl/SSLPeerUnverifiedException
            rajendra85

            Hi,

             

              Here am pasting my code for sending mail that I used in my managed bean :

            ------------------------------------------------------------------------------------------------------------------------

             

            String toWhom = "abcd@gmail.com";

            String password = "abcdef";

            String fromWhom = "web@gmail.com";

            String host = "smtp.gmail.com";

            String mailSubject = "Hi How are you ??";

            String mailText= "Gmail Send Email Demo";


            Properties properties = System.getProperties();

             

            properties.setProperty("mail.smtp.host", host);

            properties.setProperty("mail.smtp.port", "25");

            properties.setProperty("mail.smtp.starttls.enable", "true");

            properties.setProperty("mail.smtps.auth", "true");

             

            Session session = Session.getDefaultInstance(properties);

            session.setDebug(true);

             

            Message message = new MimeMessage(session);

            message.setSentDate(new Date());

            message.setFrom(new InternetAddress(fromWhom));

            message.setRecipient(Message.RecipientType.TO, new InternetAddress(toWhom));

            message.setSubject(mailSubject);

            message.setText(mailText);

            Transport.send(message);

             

            System.out.println("Done successfully");

             

             

            and Here is my  module.xml   which is located at --- >  boss-as-web-7.0.0.Final/modules/javax/mail/api/main

            ---------------------------------------------------------------------------------------------------------

             

            <?xml version="1.0" encoding="UTF-8"?>

            <module xmlns="urn:jboss:module:1.0" name="javax.mail.api">

                <dependencies>

                    <module name="javax.activation.api" export="true"/>

                </dependencies>

                <resources>

                    <resource-root path="mail-1.4.4.jar"/>

                </resources>

            </module>

             

              Am not getting Is there any jar files that i need to add as a dependency or any module to add as a dependency ??

            • 3. Re: Problem with JBoss AS 7.0 Final + Java Mail + java.lang.NoClassDefFoundError: javax/net/ssl/SSLPeerUnverifiedException
              ctomc

              Hi,

               

              edit javax.mail.api module

               

              to also have dependancy

               

              <module name="javax.api"/>

               

               

              it should fix your problem.

               

               

              --

              tomaz

              • 4. Re: Problem with JBoss AS 7.0 Final + Java Mail + java.lang.NoClassDefFoundError: javax/net/ssl/SSLPeerUnverifiedException
                rajendra85

                Hi Tomaz Cerar,

                 

                    Thank you very much .... . Your suggestion solved my problem.. Once again thank u...

                 

                The correct solution is : In JBoss AS 7 - JBoss 7.0 Final / modules / javax / mail / api / main / module.xml ;  We have to add 

                 

                <?xml version="1.0" encoding="UTF-8"?>

                <module xmlns="urn:jboss:module:1.0" name="javax.mail.api">

                    <dependencies>

                        <module name="javax.activation.api" export="true"/>

                          <module name="javax.api"/> <!-- We have to add this line for recognizing the SSL Class  -->

                    </dependencies>

                    <resources>

                        <resource-root path="mail-1.4.4.jar"/>

                    </resources>

                </module>