Java SSL Probleme unter OpenJDK 7

CA3D0

Lt. Commander
Registriert
Apr. 2011
Beiträge
1.141
Hi,

Ich habe ein kurzes Programm geschrieben, dass automatisch Emails von einem gmail konto abfragt per javamail. das funktioniert unter Windows und Oracle Java auch perfekt, aber unter Linux bekomme ich eine Exception.
Der code ist ungefähr dieser: http://www.technicalkeeda.com/java/how-to-access-gmail-inbox-using-java-imap

es funktioniert mit:
Windows 7
Java 7 u 51

dann exportiere ich in Eclipse das Projekt als jar (mit Library in der jar)
und es funktioniert nicht mit:
Raspberri Pi
Arch Linux
OpenJDK7

die Exception:
Code:
javax.mail.MessagingException: Remote host closed connection during handshake;
  nested exception is:
        javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
        at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:726)
        at javax.mail.Service.connect(Service.java:364)
        at javax.mail.Service.connect(Service.java:245)
        at mailServer.Transmit.recieve(Transmit.java:32)
        at mailServer.Test.main(Test.java:12)
Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:946)
        at sun.security.ssl.SSLSocketImpl.waitForClose(SSLSocketImpl.java:1705)
        at sun.security.ssl.HandshakeOutStream.flush(HandshakeOutStream.java:122)
        at sun.security.ssl.Handshaker.sendChangeCipherSpec(Handshaker.java:972)
        at sun.security.ssl.ClientHandshaker.sendChangeCipherAndFinish(ClientHandshaker.java:1087)
        at sun.security.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:1006)
        at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:285)
        at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
        at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
        at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:543)
        at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:348)
        at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:236)
        at com.sun.mail.iap.Protocol.<init>(Protocol.java:117)
        at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:121)
        at com.sun.mail.imap.IMAPStore.newIMAPProtocol(IMAPStore.java:746)
        at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:689)
        ... 4 more
Caused by: java.io.EOFException: SSL peer shut down incorrectly
        at sun.security.ssl.InputRecord.read(InputRecord.java:482)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927)
        ... 23 more
Exception in thread "main" java.lang.NullPointerException:
        at mailServer.Test.main(Test.java:14)

Liegt es am code oder am System?

Edit:
Habe jetzt nochmal rumgespielt und es auch geschafft einmal abzufragen, aber beim nächsten mal gab es wieder eine andere Fehlermeldung:

Code:
javax.mail.MessagingException: Broken pipe;
  nested exception is:
        java.net.SocketException: Broken pipe
        at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:726)
        at javax.mail.Service.connect(Service.java:364)
        at javax.mail.Service.connect(Service.java:245)
        at mailServer.Transmit.recieve(Transmit.java:32)
        at mailServer.Test.main(Test.java:12)
Caused by: java.net.SocketException: Broken pipe
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:159)
        at sun.security.ssl.OutputRecord.writeBuffer(OutputRecord.java:377)
        at sun.security.ssl.OutputRecord.write(OutputRecord.java:363)
        at sun.security.ssl.SSLSocketImpl.writeRecordInternal(SSLSocketImpl.java:830)
        at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:801)
        at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:672)
        at sun.security.ssl.Handshaker.sendChangeCipherSpec(Handshaker.java:966)
        at sun.security.ssl.ClientHandshaker.sendChangeCipherAndFinish(ClientHandshaker.java:1087)
        at sun.security.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:1006)
        at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:285)
        at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
        at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
        at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:543)
        at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:348)
        at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:236)
        at com.sun.mail.iap.Protocol.<init>(Protocol.java:117)
        at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:121)
        at com.sun.mail.imap.IMAPStore.newIMAPProtocol(IMAPStore.java:746)
        at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:689)
        ... 4 more
Exception in thread "main" java.lang.NullPointerException:
        at mailServer.Test.main(Test.java:14)

Edit2: habe ein wenig mehr rumgespielt, wenn ich immer noch store.close() ausführe funktioniert es jedes zweite mal, aber die Hälfte der Fälle crasht es mit dem ersten Fehler
 
Zuletzt bearbeitet:
Es funktioniert aktuell jedes zweite mal, deshalb würde ich vermuten, dass es ist und das Problem an OpenJDK liegt, ich werde wohl mal versuchen Oracle Java zu installieren und schaue was dann passiert

edit: habe mal session.setDebug(true) gemacht, das kam raus:

Code:
DEBUG: setDebug: JavaMail version 1.5.2
DEBUG: getProvider() returning javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle]
DEBUG IMAPS: mail.imap.fetchsize: 16384
DEBUG IMAPS: mail.imap.ignorebodystructuresize: false
DEBUG IMAPS: mail.imap.statuscachetimeout: 1000
DEBUG IMAPS: mail.imap.appendbuffersize: -1
DEBUG IMAPS: mail.imap.minidletime: 10
DEBUG IMAPS: trying to connect to host "smtp.gmail.com", port 993, isSSL true
javax.mail.MessagingException: Remote host closed connection during handshake;
  nested exception is:
        javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
        at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:726)
        at javax.mail.Service.connect(Service.java:364)
        at javax.mail.Service.connect(Service.java:245)
        at mailServer.Transmit.recieve(Transmit.java:36)
        at mailServer.Test.main(Test.java:12)
Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:946)
        at sun.security.ssl.SSLSocketImpl.waitForClose(SSLSocketImpl.java:1705)
        at sun.security.ssl.HandshakeOutStream.flush(HandshakeOutStream.java:122)
        at sun.security.ssl.Handshaker.sendChangeCipherSpec(Handshaker.java:972)
        at sun.security.ssl.ClientHandshaker.sendChangeCipherAndFinish(ClientHandshaker.java:1087)
        at sun.security.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:1006)
        at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:285)
        at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
        at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
        at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:543)
        at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:348)
        at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:236)
        at com.sun.mail.iap.Protocol.<init>(Protocol.java:117)
        at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:121)
        at com.sun.mail.imap.IMAPStore.newIMAPProtocol(IMAPStore.java:746)
        at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:689)
        ... 4 more
Caused by: java.io.EOFException: SSL peer shut down incorrectly
        at sun.security.ssl.InputRecord.read(InputRecord.java:482)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927)
        ... 23 more
Ergänzung ()

Ich habe jetzt Oracle Java installiert und der Fehler ist noch nicht aufgetauchtt. Wahrscheinlich lag es an OpenJDK
 
Zuletzt bearbeitet:

Ähnliche Themen

Zurück
Oben