Hi @Kian-Lee Ng
Glad to know that your issue is resolved now, and thanks for sharing the solution above! Since our forum has the policy that The question author cannot accept their own answer. They can only accept answers by others, and according to the scenario introduced here: Answering your own questions on Microsoft Q&A
I would make a brief summary of this post so that other forum members could easily find useful information here:
[Java Powershell Exchangeonline in Tomcat directly doesn't work but using tomcat in netbean works - Summary]
Issue Symptom:
The java code(which is used to start a powershell script that connect using Connect-ExchangeOnline) works perfectly when invoking it from command line and from within a JSP with the tomcat within Netbean IDE.
However, when run the same JSP in just tomcat itself (without Netbean) it hang with error timeout.
Solution:
The issue is solved by dedicating an account in "This Account" under the "Log On" tab of the Tomcat "Services".
You could "Accept Answer" for this summary to close this thread, and your action would be helpful to other users who encounter the same issue and read this thread. Thanks for your understanding!
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.