java - NullPointerException when trying to print a mail message -
java - NullPointerException when trying to print a mail message -
i have programme uses javamail retrieve messages exchange server using imap protocol process each messages has been unseen.
recently have come across problem of programme throwing nullpointerexception know unitialized object invoking method, in case not create sense me.
the stacktrace of exception follows:
java.lang.nullpointerexception @ com.sun.mail.imap.imapfolder.handleresponse(imapfolder.java:1905) @ com.sun.mail.iap.protocol.notifyresponsehandlers(protocol.java:135 @ com.sun.mail.imap.protocol.imapprotocol.fetchbodystructure(imapprotocol.java:617) @ com.sun.mail.imap.imapmessage.loadbodystructure(imapmessage.java:1027) @ com.sun.mail.imap.imapmessage.getcontenttype(imapmessage.java:321) @ javax.mail.internet.mimebodypart.ismimetype(mimebodypart.java:802) @ javax.mail.internet.mimemessage.ismimetype(mimemessage.java:851) @ ctt.mail.filehandler.putfilesfrommail(filehandler.java:75) @ ctt.mail.filehandler.main(filehandler.java:37)
aditionaly i've got debug trace lastly processed message a607 fetch 202 (flags)
* 202 fetch (flags (\seen)) a607 ok fetch completed. a608 fetch 202 (envelope internaldate rfc822.size) * 202 fetch (envelope ("mon, 14 jul 2014 15:33:56 +0100" "=?iso-8859-1?q?gpese_-_ pr=e9=5faviso_de_expedi=e7=e3o?=" (("srs0+83ffd8147b51e356=4j=solicitador.net=gpese@solicitador.net" nil "srs0+83ffd8147b51e356=4j=solicitador.net=gpese" "solicitador.net")) nil nil (("=?iso-8859-1?q?rece=c7=c3o_ficheiros_ctt_winreg?=" nil "cttwinreg" "ctt.pt")) (("caraujo@caso.pt" nil "caraujo" "caso.pt")) nil nil "<1890939061.7011405348433043.javamail.gpese@solicitador.net>") internaldate "14-jul-2014 15:33:58 +0100" rfc822.size 6462) a608 ok fetch completed. a609 fetch 202 (bodystructure) * 202 fetch (bodystructure (("text" "plain" ("charset" "iso-8859-1") nil nil "quoted-printable" 0 0 nil nil nil nil)("text" "xml" ("name" "gpese - ge_369515.xml") nil "gpese - ge_369515.xml" "base64" 5202 67 nil ("attachment" ("filename" "gpese - ge_369515.xml" "size" "3865" "creation-date" "mon, 14 jul 2014 14:33:58 gmt" "modification-date" "mon, 14 jul 2014 14:33:58 gmt")) nil nil) "mixed" ("boundary" "_002_18909390617011405348433043javamailgpesesolicitadornet_") nil "pt-pt")) * 24457 fetch (flags (\seen)) * 24458 fetch (flags (\seen)) * 24459 fetch (flags (\seen)) * 24460 fetch (flags (\seen \recent)) * 24461 fetch (flags (\seen \recent)) * 24462 fetch (flags (\seen \recent)) a609 ok fetch completed.
the line throwing exception in case debug line :
system.out.println("mensagem n.ยบ " + + " de " + (new internetaddress()).tostring(message[i].getfrom()) + " com o assunto " + message[i].getsubject() + " recebida em " + (new simpledateformat("dd/mm/yyyy hh:mm:ss")).format(message[i].getreceiveddate()) + ". nova? " + msgflags.contains(javax.mail.flags.flag.recent) + ". tem attachments mixed? " + message[i].ismimetype("multipart/mixed") + ". tem attachments alternative? " + message[i].ismimetype("multipart/alternative") + ". tem attachments alternative? " + message[i].ismimetype("") + ". o mime type \351? " + message[i].getcontenttype());
so problem in case in 1 of message[i].ismimetype(); experience exception can thrown method such message[i].getflags().
i've tested message[i] null , it's not null, thats why dont understand why exception been thrown.
any help appreciated. thanks.
edit: additional stack trace exception have collected
java.lang.nullpointerexception @ com.sun.mail.imap.imapfolder.handleresponse(imapfolder.java:1905) @ com.sun.mail.iap.protocol.notifyresponsehandlers(protocol.java:135) @ com.sun.mail.imap.protocol.imapprotocol.fetchflags(imapprotocol.java:745) @ com.sun.mail.imap.imapmessage.loadflags(imapmessage.java:1093) @ com.sun.mail.imap.imapmessage.getflags(imapmessage.java:704) @ ctt.mail.filehandler.putfilesfrommail(filehandler.java:58) java.lang.nullpointerexception @ com.sun.mail.imap.imapfolder.handleresponse(imapfolder.java:1905) @ com.sun.mail.imap.imapfolder.handleresponses(imapfolder.java:1926) @ com.sun.mail.imap.imapmessage.loadenvelope(imapmessage.java:985) @ com.sun.mail.imap.imapmessage.getreceiveddate(imapmessage.java:278) @ ctt.mail.filehandler.putfilesfrommail(filehandler.java:63)
what version of javamail using? looks nullpointerexception occurring in javamail imap provider. stack trace looks might old version of javamail.
java nullpointerexception javamail
Comments
Post a Comment