# Invoke Java method Failed

**URL:** <https://forum.uipath.com/t/invoke-java-method-failed/495053>\
**Category:** Activities\
**Tags:** question, java, activities\
**Created:** [November 30, 2022, 10:01am UTC](https://forum.uipath.com/t/invoke-java-method-failed/495053 "2022-11-30T10:01:13Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![pushkar.singh](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/pushkar.singh/32/267109_2.png) [@pushkar.singh](https://forum.uipath.com/u/pushkar.singh)\
**Post date:** [November 30, 2022, 10:01am UTC](https://forum.uipath.com/t/invoke-java-method-failed/495053/1 "2022-11-30T10:01:13Z")

</div>

I am trying to invoke java code. In my code, I’ve imported a library also. When I am running my uipath work flow, I am getting failed for invoke java method due to below reason:

RemoteException wrapping System.AggregateException: One or more errors occurred. —\> RemoteException wrapping System.InvalidOperationException: The method could not be invoked. —\> RemoteException wrapping System.InvalidOperationException: An invocation exception has occured during the execution of the target.Invocation target exceptions:java.lang.NoClassDefFoundError: com/thed/zephyr/cloud/rest/ZFJCloudRestClient  
com.Test.jwt.jwtMethod(jwt.java:63)Java Invoker program exception:java.lang.reflect.InvocationTargetExceptionat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at com.uipath.instance.ObjectInstance.InvokeMethod(ObjectInstance.java:141)at com.uipath.invoker.InvokerContext.invokeStaticMethod(InvokerContext.java:165)at com.uipath.invoker.InvokerContext.invokeStaticMethod(InvokerContext.java:40)at com.uipath.server.DotNetProcessRequest.processRequest(DotNetProcessRequest.java:52)at com.uipath.Main.main(Main.java:46)Caused by: java.lang.NoClassDefFoundError: com/thed/zephyr/cloud/rest/ZFJCloudRestClientat com.Test.jwt.jwtMethod(jwt.java:63)… 9 moreCaused by: java.lang.ClassNotFoundException: com.thed.zephyr.cloud.rest.ZFJCloudRestClientat java.net.URLClassLoader.findClass(URLClassLoader.java:381)at java.lang.ClassLoader.loadClass(ClassLoader.java:424)at java.lang.ClassLoader.loadClass(ClassLoader.java:357)… 10 more  
at UiPath.Java.Service.JavaResponse.ThrowExceptionIfNeeded() at UiPath.Java.JavaInvoker.d\_\_17.MoveNext()— End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at UiPath.Java.JavaInvoker.d\_\_14.MoveNext()— End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at UiPath.Java.Activities.InvokeJavaMethod.d\_\_16.MoveNext()  
— End of inner exception stack trace —  
at UiPath.Java.Activities.InvokeJavaMethod.d\_\_16.MoveNext()

---

<div class="post-metadata">

**Author:** ![exonautomation](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/exonautomation/32/404316_2.png) [@exonautomation](https://forum.uipath.com/u/exonautomation)\
**Post date:** [November 30, 2022, 10:41am UTC](https://forum.uipath.com/t/invoke-java-method-failed/495053/2 "2022-11-30T10:41:58Z")

</div>

> [@pushkar.singh](#):
>
> RemoteException wrapping System.AggregateException

Share screenshot on your work flow

---

<div class="post-metadata">

**Author:** ![pushkar.singh](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/pushkar.singh/32/267109_2.png) [@pushkar.singh](https://forum.uipath.com/u/pushkar.singh)\
**Post date:** [November 30, 2022, 11:04am UTC](https://forum.uipath.com/t/invoke-java-method-failed/495053/3 "2022-11-30T11:04:52Z")

</div>

[Java Code.docx](https://forum.uipath.com/uploads/short-url/nKDlXSfSYdTml618IPBBh9tOdI1.docx) (181.1 KB)

---

<div class="post-metadata">

**Author:** ![exonautomation](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/exonautomation/32/404316_2.png) [@exonautomation](https://forum.uipath.com/u/exonautomation)\
**Post date:** [November 30, 2022, 12:26pm UTC](https://forum.uipath.com/t/invoke-java-method-failed/495053/4 "2022-11-30T12:26:36Z")

</div>

Have you install UiPath Java Extension on your UiPath Studio?

---

<div class="post-metadata">

**Author:** ![pushkar.singh](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/pushkar.singh/32/267109_2.png) [@pushkar.singh](https://forum.uipath.com/u/pushkar.singh)\
**Post date:** [November 30, 2022, 12:34pm UTC](https://forum.uipath.com/t/invoke-java-method-failed/495053/5 "2022-11-30T12:34:55Z")

</div>

Are you talking about Uipath.java.activities? If yes, it is already installed that’s why we are able to create work flow.

I’ve created a new JAR with simple program and it is working fine with return string value. In my previous program, i am importing a library so UiPath is not executing it. Any help.

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [December 1, 2022, 12:17pm UTC](https://forum.uipath.com/t/invoke-java-method-failed/495053/6 "2022-12-01T12:17:34Z")

</div>

> [@pushkar.singh](#):
>
> NoClassDefFoundError: com/thed/zephyr/cloud/rest/ZFJCloudRestClient

Hi @pushkar.singh

It looks more like the imported library issue as stated already. So can you check if ypu have imported the right library and the class path are added in env variables and library is present

Please check thsi thread as well. Not all steps might be applicable but you can see few might help as resolution steps

> <https://stackoverflow.com/questions/48298900/how-to-generate-jwt-token-for-jira-api>

Let me know if you still face the issue .

And alternately if the code is working from ajava env then once try changing the package and see if its the package issue

Cheers

---

<div class="post-metadata">

**Author:** ![pushkar.singh](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/pushkar.singh/32/267109_2.png) [@pushkar.singh](https://forum.uipath.com/u/pushkar.singh)\
**Post date:** [December 1, 2022, 1:21pm UTC](https://forum.uipath.com/t/invoke-java-method-failed/495053/7 "2022-12-01T13:21:05Z")

</div>

I am able to run with eclipse tool. Token is getting generated. Same project is exported as a jar and path is given in Uipath. It throws an error while invoking java method.

I tried to run a simple java program where i passed a string value and it returned the results to me in Uipath but here we are not importing any class since it is a basic test program to test where it works or not. So problem is importing library in case of uipath.

To import lib, I simply did it manually in eclipse but uipath is not importing it.

---

<div class="post-metadata">

**Author:** ![pushkar.singh](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/pushkar.singh/32/267109_2.png) [@pushkar.singh](https://forum.uipath.com/u/pushkar.singh)\
**Post date:** [December 1, 2022, 1:26pm UTC](https://forum.uipath.com/t/invoke-java-method-failed/495053/8 "2022-12-01T13:26:07Z")

</div>

Do I have to define maven project with dependency?

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [December 1, 2022, 1:35pm UTC](https://forum.uipath.com/t/invoke-java-method-failed/495053/9 "2022-12-01T13:35:20Z")

</div>

Hi @pushkar.singh

Ideally from error i can infer that it is not able to find the required package …try debugging and see if there is any path it is looking at or any other information you get from the inner exception message details from locals panel

Defining dependencies and linking that also might help , we have to somehow out point the dependencies to it . That is the end goal though

Cheers

---

<div class="post-metadata">

**Author:** ![pushkar.singh](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/pushkar.singh/32/267109_2.png) [@pushkar.singh](https://forum.uipath.com/u/pushkar.singh)\
**Post date:** [December 1, 2022, 2:13pm UTC](https://forum.uipath.com/t/invoke-java-method-failed/495053/10 "2022-12-01T14:13:20Z")

</div>

debugging does not help. I am getting this feeling that it is not importing lib. If i manually added zip library and created jar, how will uipath/java import it again?

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [December 1, 2022, 2:49pm UTC](https://forum.uipath.com/t/invoke-java-method-failed/495053/11 "2022-12-01T14:49:24Z")

</div>

@pushkar.singh

I agree with you on it not importing the library s the error says so. But what we are trying is to get uipath to somehow point to library that we want to import. Let me try and check if i can find any way to do it

Cheers

---

<div class="post-metadata">

**Author:** ![pushkar.singh](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/pushkar.singh/32/267109_2.png) [@pushkar.singh](https://forum.uipath.com/u/pushkar.singh)\
**Post date:** [December 1, 2022, 3:27pm UTC](https://forum.uipath.com/t/invoke-java-method-failed/495053/12 "2022-12-01T15:27:20Z")

</div>

Brilliant. Thank You.
