Free Support Forum - aspose.com

Exception: The remote server returned error 404 on opening EWSClient (Java)

Hi team,

I am a beginner with the Aspose.Email API and I am trying to test the getEWSClient method using the below code:

package DLTest;

import java.io.File;
import com.aspose.email.EWSClient;
import com.aspose.email.IEWSClient;
import com.aspose.email.License;

public class TestFetchDL {

void print(){
	IEWSClient client = EWSClient.getEWSClient("https://outlook.office365.com/ews/exchange.asmx", "UserOne@ASE1982.onmicrosoft.com", "Aspose1234");
	
	System.out.println("success" + client.listMessages());

}


public static void main(String[] args) {
	
	TestFetchDL testFetchDL = new TestFetchDL();
	testFetchDL.print();
	// TODO Auto-generated method stub

}

}

While running the code, I am getting the below error. Can you please let me know how to resolve it?

Exception in thread “main” java.lang.IllegalStateException: class com.aspose.email.system.exceptions.WebException: The remote server returned an error: (404) Not Found.
com.aspose.email.internal.m.z.b(Unknown Source)
com.aspose.email.internal.m.z.a(Unknown Source)
com.aspose.email.internal.m.bf.a(Unknown Source)
com.aspose.email.internal.m.bg.invoke(Unknown Source)
com.aspose.email.system.d.a(Unknown Source)
com.aspose.email.internal.ck.c.a(Unknown Source)
com.aspose.email.internal.af.j.run(SourceFile:66)
java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
at com.aspose.email.pj.a(SourceFile:256)
at com.aspose.email.pj.a(SourceFile:321)
at com.aspose.email.EWSClient.getEWSClient(SourceFile:300)
at com.aspose.email.EWSClient.getEWSClient(SourceFile:80)
at DLTest.TestFetchDL.print(TestFetchDL.java:10)
at DLTest.TestFetchDL.main(TestFetchDL.java:21)
Caused by: class com.aspose.email.system.exceptions.WebException: The remote server returned an error: (404) Not Found.
com.aspose.email.internal.m.z.b(Unknown Source)
com.aspose.email.internal.m.z.a(Unknown Source)
com.aspose.email.internal.m.bf.a(Unknown Source)
com.aspose.email.internal.m.bg.invoke(Unknown Source)
com.aspose.email.system.d.a(Unknown Source)
com.aspose.email.internal.ck.c.a(Unknown Source)
com.aspose.email.internal.af.j.run(SourceFile:66)
java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
at com.aspose.email.internal.m.z.b(Unknown Source)
at com.aspose.email.internal.m.z.a(Unknown Source)
at com.aspose.email.internal.m.bf.a(Unknown Source)
at com.aspose.email.internal.m.bg.invoke(Unknown Source)
at com.aspose.email.system.d.a(Unknown Source)
at com.aspose.email.internal.ck.c.a(Unknown Source)
at com.aspose.email.internal.af.j.run(SourceFile:66)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

@Prateep,

You are using a test account that we created few months back for testing and is no more valid now. Please create a test account on Office 365 and try the same code with that new account. Please let us know if you come across any issue. We’ll look into it for assisting you further.

Hi,

I tried running the same code with my company’s Microsoft Outlook details and it threw the below error.

Exception in thread “main” java.lang.IllegalStateException: class com.aspose.email.system.exceptions.WebException: Error: NameResolutionFailure
com.aspose.email.internal.m.z.a(Unknown Source)
com.aspose.email.internal.m.bf.b(Unknown Source)
com.aspose.email.internal.m.bf.a(Unknown Source)
com.aspose.email.internal.m.bh.a(Unknown Source)
com.aspose.email.internal.af.j.run(SourceFile:66)
java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
at com.aspose.email.pj.a(SourceFile:256)
at com.aspose.email.pj.a(SourceFile:321)
at com.aspose.email.EWSClient.getEWSClient(SourceFile:300)
at com.aspose.email.EWSClient.getEWSClient(SourceFile:80)
at DLTest.TestFetchDL.print(TestFetchDL.java:10)
at DLTest.TestFetchDL.main(TestFetchDL.java:21)
Caused by: class com.aspose.email.system.exceptions.WebException: Error: NameResolutionFailure
com.aspose.email.internal.m.z.a(Unknown Source)
com.aspose.email.internal.m.bf.b(Unknown Source)
com.aspose.email.internal.m.bf.a(Unknown Source)
com.aspose.email.internal.m.bh.a(Unknown Source)
com.aspose.email.internal.af.j.run(SourceFile:66)
java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
at com.aspose.email.internal.m.z.a(Unknown Source)
at com.aspose.email.internal.m.bf.b(Unknown Source)
at com.aspose.email.internal.m.bf.a(Unknown Source)
at com.aspose.email.internal.m.bh.a(Unknown Source)
at com.aspose.email.internal.af.j.run(SourceFile:66)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

The fetched the Mailbox URI using the second method (Availability service URL) mentioned in https://support.neuxpower.com/hc/en-us/articles/202482832-Determining-the-Exchange-Web-Services-EWS-URL

I even tried using the ExchangeClient as mentioned below, but the same error was thrown.

ExchangeClient client = new ExchangeClient(“https://#exch-server#/EWS/Exchange.asmx”, "xyz@abc.com", “werjkw@”);
System.out.println(“success” + client.getMailboxSize());

Any idea how to resolve it?

Regards,
Prateep

@Prateep,

We don’t see any issue with the usage of EWS client here. ExchangeClient, however, is used with WebDav protocol in Exchange Server 2003 and 2007 (the protocol itself is no more supported). The issue of NameResolutionFailure seems specific to your server and we need test account on your server to further investigate this. Also, please make sure that you are using the latest version of the API at your end.

Hi,

Thanks for your assistance.
I made some changes to the credential and it is working fine now.

I just want to ask one thing that the aspose.email jar that I have downloaded for my Java application is valid for my usage for as long as I want or there is any expiration date for that. I do have come across some other products which say that the evaluation version will not work after a certain period of time.

Regards,
Prateep

@Prateep,

A temporary license is valid for 30 days where as for valid license you may please open the .lic file in some editor and search the tag date. This date shows that this license is valid for all the product versions which are released before this date. Please check your license validity as mentioned above and use product version accordingly.

Please feel free to write us back if you have any other query in this regard.

@kashif.iqbal,

Please help me understand this in better way.

I have downloaded aspose-email-17.7-java.zip from https://downloads.aspose.com/email/java and from the zip, I am just adding the “aspose-email-17.7-jdk16.jar” as external jar in my Java project (nothing else from the zip)

I checked the complete zip, but I do not see any expiration date. Will there be any issue after 30 days? I don’t think that jar goes dead after some days.

@Prateep,

This is more related to the license file that you will use in your application. If you don’t use licence in your application, you will face these evaluation limitations. If you want to try the API without these evaluation limitations, you can get a 30-day temporary license free of cost and initialize it in your application. Once the trial period (30 days) is over, you will start getting exception with the temporary license you used in your application. The expiry date lies inside the license file and not in the download zip file of the API. I hope this clarifies your concerns.

Thank you for this information. Currently, I am not facing any kind of limitations as such.
I will get back to you in case of any future issues.

@Prateep,

Thank you for feedback. The evaluation limitations will happen once you download some email using the client.fetchMessage method from the server. You will see evaluation version limitations as shown in this screenshot: http://prntscr.com/g05ku4 . Anyways, please feel free to write to us if you have any further inquiry about the API.

when i m using ExchangeClient to establish connection it is showing connected but when i try to retrieve message from it it is showing

xception in thread “main” ExchangeException: The remote server returned an error: (405) Method Not Allowed.
—> class com.aspose.email.system.exceptions.WebException: The remote server returned an error: (405) Method Not Allowed.
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(Unknown Source)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
— End of inner exception stack trace —
[Ljava.lang.StackTraceElement;@1907bac
at com.aspose.email.ExchangeClient.getMailboxInfo(SourceFile:592)
at com.aspose.email.ExchangeClient.getMailboxInfo(SourceFile:254)
at com.aspose.email.examples.exchangewebdav.FetchMessagesFromAnExchangeServerMailbox.fetchMessagesFromAnExchangeServerMailbox(FetchMessagesFromAnExchangeServerMailbox.java:20)
at com.aspose.email.examples.exchangewebdav.FetchMessagesFromAnExchangeServerMailbox.main(FetchMessagesFromAnExchangeServerMailbox.java:12)
Caused by: class com.aspose.email.system.exceptions.WebException: The remote server returned an error: (405) Method Not Allowed.
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(Unknown Source)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
at com.aspose.email.internal.o.zab.b(Unknown Source)
at com.aspose.email.internal.o.zab.a(Unknown Source)
at com.aspose.email.internal.o.zbh.a(Unknown Source)
at com.aspose.email.internal.o.zbi.invoke(Unknown Source)
at com.aspose.email.system.zd.a(Unknown Source)
at com.aspose.email.internal.ex.zc.a(Unknown Source)
at com.aspose.email.internal.ah.zg.run(SourceFile:66)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

@Mannu_rawat,

I have observed your issue and request you to please firs try using latest Aspose.Email for Java 19.10. In case there is still an issue, please share the working sample code along with test account credentials reproducing the issue on your end.