Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6564181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:56:05+00:00 2026-05-25T13:56:05+00:00

I know this question is asked before but I think it was 2-3 years

  • 0

I know this question is asked before but I think it was 2-3 years before and things have changed since then. None of the code samples is working now.
I am trying the following code in Java 1.6:

Properties props = new Properties();
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", "smtp.gmail.com");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
props.put("mail.debug", "true");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() {
    protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication("uname","password");
    }
});
session.setDebug(true);
Transport transport = session.getTransport();
InternetAddress addressFrom = new InternetAddress("abc@gmail.com");
MimeMessage message = new MimeMessage(session);
message.setSender(addressFrom);

for (int j = 0; j < 20; j++) {
    message.setSubject("Testing javamail plain"+Math.random());
    message.setContent("This is a test", "text/plain");
    String sendTo [] = {"abc@gmail.com"};
    if (sendTo != null) {
        InternetAddress[] addressTo = new InternetAddress[sendTo.length];
        for (int i = 0; i < sendTo.length; i++) {
            addressTo[i] = new InternetAddress(sendTo[i]);
        }
        message.setRecipients(Message.RecipientType.TO, addressTo);
    }
    transport.connect();
    Transport.send(message);
    transport.close();
    System.out.println("DONE");
}

and it throws this exception:

org.apache.cxf.interceptor.Fault: javax.mail.NoSuchProviderException: Unable to locate provider for protocol: smtp
org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:155)
org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:121)
org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:164)
org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:91)
org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
java.util.concurrent.FutureTask.run(FutureTask.java:138)
org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:206)
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:218)
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:161)
org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:114)
org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:184)
org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:112)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:163)

I am using tomcat as webserver and cxf framefork for webservices.
Any help is much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:56:05+00:00Added an answer on May 25, 2026 at 1:56 pm

    I assume that you have java.mail jar file in your class path and cxf supporting jar files. Actually CXF makes use of Apache Geronimo Javamail/activation implementations, so now you will have two different versions of Sun’s Javamail libraries in your application classpath, When your application tries to send an email, Java gets confused as to which version of the library it should be using, and falls over. So the solution might be either removing the javamail jar file or to exclude the geronimo javamail in the pom file like :

    <exclusions>          
         <exclusion>               
             <groupId>org.apache.geronimo.specs</groupId>  
             <artifactId>geronimo-javamail_1.4_spec</artifactId>    
         </exclusion>
         <exclusion>  
              <groupId>org.apache.geronimo.specs</groupId>   
              <artifactId>geronimo-activation_1.1_spec</artifactId> 
         </exclusion>  
    

    Hope this help you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question was asked before but I have the following simple code
I know this question has been asked here before, but I don't think those
I know this question has been asked before, but none of the existing SO
I know similar questions have been asked before but i think this is slightly
I know this question has been asked and answered before, but none of the
I know this is a question that has been asked before, but I think
This question has to have been asked before, but I think the search terms
I know this question has been asked before, but I ran into a problem.
I know this specific question has been asked before , but I am not
I know this question has been asked a bit before. But looking around I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.