Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Error -The trustAnchors parameter must be non-empty.

843811May 20 2010 — edited May 25 2010
Hi to all,
i ve a send mail program, which i modified fm smtpsend.java,the sample come with javamail 1.4.3. this is working when i run from command prompt. but when i run this inside in jdeveloper 11g "the trustAnchors parameter must be non-empty" error is coming.
i m using Weblogic Server 11g(10.3.2) & jdk6 update 16.

Can anyone help me? wt is problem here?

C:\Middleware11g2\jdk160_14_R27.6.5-32\bin\javaw.exe -client -classpath C:\JDeveloper\mywork\MyTestApp\classes;C:\JDeveloper\mywork\WorkFlow\javamail-1.4.3\javamail-1.4.3\mail.jar "-Djavax.net.ssl.trustStore=D:\Middleware11g 2\wlserver_10.3\server\lib\DemoTrust.jks" com.company.jsf.TestSmtp
javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465;
nested exception is:
javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty.

-------------------------------------------------------
package com.company.jsf;

import com.sun.mail.smtp.SMTPTransport;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.SendFailedException;
import javax.mail.Session;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class TestSmtp {
public TestSmtp() {
super();
}

public static void main(String[] args){
String to="recipient@yahoo.com", subject = "Hi", from = "myid@gmail.com", cc = null, bcc = null, url = null;
String mailhost = "smtp.gmail.com";

String user = "myid", password = "mypassword";
boolean debug = false;
boolean verbose = false;
boolean auth = true;
String prot = "smtps";

try{


Properties props = System.getProperties();
if (mailhost != null)
props.put("mail." prot ".host", mailhost);
if (auth)
props.put("mail." prot ".auth", "true");


// Get a Session object
Session session = Session.getInstance(props, null);
if (debug)
session.setDebug(true);
Message msg = new MimeMessage(session);
if (from != null)
msg.setFrom(new InternetAddress(from));


msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to, false));
if (cc != null)
msg.setRecipients(Message.RecipientType.CC, InternetAddress.parse(cc, false));
if (bcc != null)
msg.setRecipients(Message.RecipientType.BCC, InternetAddress.parse(bcc, false));

msg.setSubject(subject);

String text = "hr u?";
msg.setText(text);

SMTPTransport t = (SMTPTransport)session.getTransport(prot);
try {
if (auth)
t.connect(mailhost, user, password);
else
t.connect();
t.sendMessage(msg, msg.getAllRecipients());
}

finally {
if (verbose)
System.out.println("Response: " + t.getLastServerResponse());
t.close();
}

System.out.println("\nMail was sent successfully.");
}
catch(Exception e){
e.printStackTrace();
}


}
}

Edited by: user7895 on May 20, 2010 12:47 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 22 2010
Added on May 20 2010
8 comments
3,417 views