We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Exceptions on Exchange EWS listMessages() and fetchItem() functions (java)

Hi,

Try to fetch messages from a Exchange server using the sample code from Fetch Messages from an Exchange Server Mailbox.
Some exceptions occurred as follows. When the exceptions occurred, it needs to wait about 2 minutes.

  1. Exception class com.aspose.email.system.exceptions.XmlException: unexpected end of file. Current
    depth is 2 Line 1, position 26292.
    com.aspose.email.internal.ai.zku.h(Unknown Source)
    com.aspose.email.internal.ai.zku.aa(Unknown Source)
    com.aspose.email.internal.ai.zku.h(Unknown Source)
    com.aspose.email.internal.ai.zkt.h(Unknown Source)
    com.aspose.email.internal.ai.zle.a(Unknown Source)
    com.aspose.email.internal.ai.zle.a(Unknown Source)
    com.aspose.email.internal.ai.zle.a(Unknown Source)
    com.aspose.email.internal.ai.zhm.K(Unknown Source)
    com.aspose.email.zahn.a(SourceFile:97)
    com.aspose.email.zsh.a(SourceFile:34)
    com.aspose.email.zg.a(SourceFile:236)
    com.aspose.email.zg.a(SourceFile:346)
    com.aspose.email.zpn.a(SourceFile:8449)
    com.aspose.email.zpn.a(SourceFile:8311)
    com.aspose.email.zpn.a(SourceFile:8258)
    com.aspose.email.zpn.a(SourceFile:8885)
    com.aspose.email.zpn.a(SourceFile:8866)
    com.aspose.email.zpn.listMessages(SourceFile:8637)

  2. class com.aspose.email.system.exceptions.XmlException: unexpected end of file. Current depth is 2 Line 1, position 51936.
    com.aspose.email.internal.ai.zku.h(Unknown Source)
    com.aspose.email.internal.ai.zku.aa(Unknown Source)
    com.aspose.email.internal.ai.zku.h(Unknown Source)
    com.aspose.email.internal.ai.zkt.h(Unknown Source)
    com.aspose.email.internal.ai.zle.a(Unknown Source)
    com.aspose.email.internal.ai.zle.a(Unknown Source)
    com.aspose.email.internal.ai.zle.a(Unknown Source)
    com.aspose.email.internal.ai.zhm.K(Unknown Source)
    com.aspose.email.zahn.a(SourceFile:97)
    com.aspose.email.zsh.a(SourceFile:34)
    com.aspose.email.zg.a(SourceFile:236)
    com.aspose.email.zg.a(SourceFile:375)
    com.aspose.email.zpn.b(SourceFile:8117)
    com.aspose.email.zpn.a(SourceFile:8096)
    com.aspose.email.zpn.fetchItem(SourceFile:8021)

  3. class com.aspose.email.system.exceptions.WebException: Error getting response stream (ReadDone1): 3 —> class com.aspose.email.system.exceptions.IOException: EndRead failure —> class com.aspose.email.system.exceptions.SocketException: An existing connection was forcibly closed by the remote host.
    com.aspose.email.internal.s.zg.c(Unknown Source)
    com.aspose.email.internal.s.zg.a(Unknown Source)
    com.aspose.email.internal.s.zg$zc.b(Unknown Source)
    com.aspose.email.internal.s.zi.a(Unknown Source)
    com.aspose.email.internal.s.zk.a(Unknown Source)
    com.aspose.email.internal.ex.zc.a(Unknown Source)
    com.aspose.email.internal.ah.zg.run(SourceFile:66)
    java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    java.util.concurrent.FutureTask.run(FutureTask.java:266)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    java.lang.Thread.run(Thread.java:748)
    — End of inner exception stack trace —
    com.aspose.email.internal.s.zf.endRead(Unknown Source)
    com.aspose.email.internal.fb.zak.c(Unknown Source)
    com.aspose.email.internal.fb.zak.b(Unknown Source)
    com.aspose.email.internal.fb.zam.invoke(Unknown Source)
    com.aspose.email.internal.s.zg$zb.b(Unknown Source)
    com.aspose.email.internal.s.zg$zb.a(Unknown Source)
    com.aspose.email.internal.s.zg$zc.b(Unknown Source)
    com.aspose.email.internal.s.zi.a(Unknown Source)
    com.aspose.email.internal.s.zk.a(Unknown Source)
    com.aspose.email.internal.ex.zc.a(Unknown Source)
    com.aspose.email.internal.ah.zg.run(SourceFile:66)
    java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    java.util.concurrent.FutureTask.run(FutureTask.java:266)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    java.lang.Thread.run(Thread.java:748)
    — End of inner exception stack trace —
    com.aspose.email.internal.o.zab.a(Unknown Source)
    com.aspose.email.internal.o.zbh.a(Unknown Source)
    com.aspose.email.internal.o.zbh.a(Unknown Source)
    com.aspose.email.internal.o.zbi.invoke(Unknown Source)
    com.aspose.email.system.zd.a(Unknown Source)
    com.aspose.email.internal.ex.zc.a(Unknown Source)
    com.aspose.email.internal.ah.zg.run(SourceFile:66)
    java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    java.util.concurrent.FutureTask.run(FutureTask.java:266)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    java.lang.Thread.run(Thread.java:748)
    — End of inner exception stack trace —
    com.aspose.email.internal.o.zab.a(Unknown Source)
    com.aspose.email.internal.o.zbh.a(Unknown Source)
    com.aspose.email.internal.o.zbh.a(Unknown Source)
    com.aspose.email.internal.o.zbi.invoke(Unknown Source)
    com.aspose.email.system.zd.a(Unknown Source)
    com.aspose.email.internal.ex.zc.a(Unknown Source)
    com.aspose.email.internal.ah.zg.run(SourceFile:66)
    java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    java.util.concurrent.FutureTask.run(FutureTask.java:266)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    java.lang.Thread.run(Thread.java:748)

  4. class com.aspose.email.system.exceptions.ObjectDisposedException: Cannot access a disposed object.
    Object name: ‘com.aspose.email.internal.s.zf’.
    com.aspose.email.internal.o.zbh.a(Unknown Source)
    com.aspose.email.internal.o.zbp.beginRead(Unknown Source)
    com.aspose.email.internal.o.zbp.read(Unknown Source)
    com.aspose.email.internal.ai.zgp.read(Unknown Source)
    com.aspose.email.internal.ai.zcp.b(Unknown Source)
    com.aspose.email.internal.ai.zcp.read(Unknown Source)
    com.aspose.email.internal.ai.zkr.read(Unknown Source)
    com.aspose.email.internal.ai.zku.h(Unknown Source)
    com.aspose.email.internal.ai.zku.Y(Unknown Source)
    com.aspose.email.internal.ai.zku.aa(Unknown Source)
    com.aspose.email.internal.ai.zku.h(Unknown Source)
    com.aspose.email.internal.ai.zkt.h(Unknown Source)
    com.aspose.email.internal.ai.zle.a(Unknown Source)
    com.aspose.email.internal.ai.zle.a(Unknown Source)
    com.aspose.email.internal.ai.zle.a(Unknown Source)
    com.aspose.email.internal.ai.zle.a(Unknown Source)
    com.aspose.email.internal.ai.zle.a(Unknown Source)
    com.aspose.email.internal.ai.zle.a(Unknown Source)
    com.aspose.email.internal.ai.zle.a(Unknown Source)
    com.aspose.email.internal.ai.zle.a(Unknown Source)
    com.aspose.email.internal.ai.zle.a(Unknown Source)
    com.aspose.email.internal.ai.zhm.K(Unknown Source)
    com.aspose.email.zahn.a(SourceFile:97)
    com.aspose.email.zsh.a(SourceFile:34)
    com.aspose.email.zg.a(SourceFile:236)
    com.aspose.email.zg.a(SourceFile:359)
    com.aspose.email.zpn.a(SourceFile:8061)
    com.aspose.email.zpn.a(SourceFile:8095)
    com.aspose.email.zpn.fetchItem(SourceFile:8021)

  5. class com.aspose.email.system.exceptions.WebException: Bad Request
    com.aspose.email.internal.o.zab.b(Unknown Source)
    com.aspose.email.internal.o.zab.a(Unknown Source)
    com.aspose.email.internal.o.zbh.a(Unknown Source)
    com.aspose.email.internal.o.zbi.invoke(Unknown Source)
    com.aspose.email.system.zd.a(Unknown Source)
    com.aspose.email.internal.ex.zc.a(Unknown Source)
    com.aspose.email.internal.ah.zg.run(SourceFile:66)
    java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    java.util.concurrent.FutureTask.run(FutureTask.java:266)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    java.lang.Thread.run(Thread.java:748)

Any suggestions?

@softnext,

I have observed the issue shared by you and request you to please try using latest Aspose.Email for Java 20.4 on your end. If there is still and issue then please share the working sample code along with test account credentials reproducing the issue on your end.

@softnext,

I have observed the information shared by you and a ticket with ID EMAILJAVA-34706 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be addressed.