Cześć,
mam problem z odbieraniem meili za pomocą Api Java Mail oto poniższa funkcja:
public ReceiveMail receiveMessages() throws NoSuchProviderException, MessagingException{
String host = "MyHost";
String user = "myLogin";
String password = "myPassword";
// Get system properties
Properties properties = System.getProperties();
properties.setProperty("mail.pop3.ssl.enable", "true");
// Poniżej używałem trzech wersji z auth, null , ogólnie z 1 argumentem w getDefaultInstance
Session session = Session.getDefaultInstance(properties, auth);
// Get a Store object that implements the specified protocol.
Store store = session.getStore("pop3");
//Connect to the current host using the specified username and password.
store.connect(host, 995, user, password );
//store.connect();
//Create a Folder object corresponding to the given name.
Folder folder = store.getFolder("inbox");
// Open the Folder.
folder.open(Folder.READ_ONLY);
Message[] message = folder.getMessages();
ReceiveMail returned = new ReceiveMail(message);
folder.close(true);
store.close();
return returned;
}
Ogólnie sprawa wygląda tak uruchomienie tej funkcji w konsoli wyświetli wiadomość ale już w Swingu + webserwice + ejb, niestety dostaje takie coś po wykonaniu tej funkcji dostaje następujacy exception:
javax.mail.MessagingException: Connect failed;
nested exception is:
javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:210)
at javax.mail.Service.connect(Service.java:295)
Co robię źle czegoś nie dodałem