Load Jar (Java Scope) is Throwing Exception in the second iteration of a For Each Loop

Hi Please help me solve this
I am using Java Scope activities in a for each loop to call a java method. Load Jar is throwing an exception “java invoker was not loaded uipath” in the second iteration. Same code is working fine in the debug mode. Please find the exception message below

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.AggregateException: One or more errors occurred. ----> System.InvalidOperationException: Java invoker was not loaded.
at UiPath.Java.Activities.JavaScope.GetJavaInvoker(ActivityContext context)
at UiPath.Java.Activities.LoadJar.d__4.MoveNext()
— End of inner ExceptionDetail stack trace —
at UiPath.Shared.Activities.AsyncTaskCodeActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

Hi @Priyank.rao,
If in debug mode all is working fine then I think you should use Delay activity after each iteration. Seems that you workflow is working that fast that it can’t load Jar in second iteration because it’s not already closed after first one. In debug mode all is working slower that’s why all is working fine. The process have enough time to free up the Jar after first loop :wink:

added Delay but still its throwing same error. Any other way to handle it ??

Are you able to check if mentioned file is not in use in the moment when error is appearing? Try to experiment. Maybe duplicate the file with other name and instead of loop try to work with the cloned file after the original one to check if problem will occur.

Hi I am able to solve it after i placed a delay of 20 seconds before java scope. Thanks for the reply :slight_smile: :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.