Invoke Java method Failed

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()

Share screenshot on your work flow

Java Code.docx (181.1 KB)

Have you install UiPath Java Extension on your UiPath Studio?

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.

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

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

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.

Do I have to define maven project with dependency?

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

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?

@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

Brilliant. Thank You.