java.lang.NoClassDefFoundError: com/azure/core/credential/AzureKeyCredential

Hello guys,

I am trying to create a testsuite and I have a problem. My goal is to make a test where I use an API to put some data in a Azure Cosmos DB SQL API database.

I am pretty new to Java and Katalon Studio so I started with the following application in IntelliJ: https://docs.microsoft.com/en-us/azure/cosmos-db/create-sql-api-java?tabs=sync
this application is build by Azure and for me it works as expected.

After that, I made the switch to Katalon.

I do have things as follows:

  • Custom Keyword called test/CosmosDBTest.groovy
  • Test Case called cosmos. One item in it, where I call “test.CosmosDbTest.createDatabaseAndContainer”

By default, the Azure Cosmos SQL API is not available in Groove scripts, so I imported it in Library management. Even for Reactor Core as it was also needed.

Testcode: (Where correct personal information is erased and the testcode is straight from the Java example mentioned earlier.)

Testcase Cosmos:

Build.gradle

Library management:

The referenced External libraries are also available in the .classpath file.

The error I get:

=============== ROOT CAUSE =====================
Caused by: java.lang.NoClassDefFoundError: com/azure/core/credential/AzureKeyCredential

For trouble shooting, please visit: https://docs.katalon.com/katalon-studio/docs/troubleshoot-common-execution-exceptions-web-test.html
================================================

01-15-2021 03:13:02 PM Test Cases/cosmos

Elapsed time: 3,035s

test.CosmosDbTest.invokeMethod:0

Test Cases/cosmos FAILED.
Reason:
org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.NoClassDefFoundError: com/azure/core/credential/AzureKeyCredential
	at test.CosmosDbTest.invokeMethod(CosmosDbTest.groovy)
	at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
	at cosmos.run(cosmos:18)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:394)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:385)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:364)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:356)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:251)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1610719978816.run(TempTestCase1610719978816.groovy:25)
Caused by: java.lang.NoClassDefFoundError: com/azure/core/credential/AzureKeyCredential
	at test.CosmosDbTest.createDatabaseAndContainer(CosmosDbTest.groovy:50)
	at test.CosmosDbTest.invokeMethod(CosmosDbTest.groovy)
	at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
	at Script1610705088548.run(Script1610705088548.groovy:18)
	... 11 more
Caused by: java.lang.ClassNotFoundException: com.azure.core.credential.AzureKeyCredential
	at test.CosmosDbTest.createDatabaseAndContainer(CosmosDbTest.groovy:50)
	at test.CosmosDbTest.invokeMethod(CosmosDbTest.groovy)
	at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
	at cosmos.run(cosmos:18)
	... 11 more

Error Log shows this:

!ENTRY org.eclipse.jdt.core 4 0 2021-01-15 15:40:06.965
!MESSAGE Code assist internal error
!STACK 0
org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(324) The type com.azure.core.credential.TokenCredential cannot be resolved. It is indirectly referenced from required .class files
	at org.eclipse.jdt.internal.compiler.problem.ProblemHandler.handle(ProblemHandler.java:161)
	at org.eclipse.jdt.internal.compiler.problem.ProblemHandler.handle(ProblemHandler.java:235)
	at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.handle(ProblemReporter.java:2389)
	at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.isClassPathCorrect(ProblemReporter.java:4733)
	at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:105)
	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:201)
	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveTypesFor(BinaryTypeBinding.java:1495)
	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.methods(BinaryTypeBinding.java:1449)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.initializeMembers(JDTClassNode.java:268)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.initialize(JDTClassNode.java:232)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTClassNode.lazyClassInit(JDTClassNode.java:163)
	at org.codehaus.groovy.ast.ClassNode.getDeclaredConstructors(ClassNode.java:579)
	at org.eclipse.jdt.groovy.search.SimpleTypeLookup.findType(SimpleTypeLookup.java:290)
	at org.eclipse.jdt.groovy.search.SimpleTypeLookup.lookupType(SimpleTypeLookup.java:85)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.lookupExpressionType(TypeInferencingVisitorWithRequestor.java:2033)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.handleSimpleExpression(TypeInferencingVisitorWithRequestor.java:2002)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitConstructorCallExpression(TypeInferencingVisitorWithRequestor.java:1440)
	at org.codehaus.groovy.ast.expr.ConstructorCallExpression.visit(ConstructorCallExpression.java:46)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitMethodCallExpression(TypeInferencingVisitorWithRequestor.java:1598)
	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitMethodCallExpression(TypeInferencingVisitorWithRequestor.java:1598)
	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitMethodCallExpression(TypeInferencingVisitorWithRequestor.java:1598)
	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitMethodCallExpression(TypeInferencingVisitorWithRequestor.java:1598)
	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitMethodCallExpression(TypeInferencingVisitorWithRequestor.java:1598)
	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitBinaryExpression(TypeInferencingVisitorWithRequestor.java:996)
	at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:51)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:74)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:281)
	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:40)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:251)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitBlockStatement(TypeInferencingVisitorWithRequestor.java:1367)
	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:148)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:159)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitConstructorOrMethod(TypeInferencingVisitorWithRequestor.java:814)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitJDT(TypeInferencingVisitorWithRequestor.java:565)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitJDT(TypeInferencingVisitorWithRequestor.java:395)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitCompilationUnit(TypeInferencingVisitorWithRequestor.java:350)
	at org.codehaus.groovy.eclipse.codebrowsing.requestor.CodeSelectHelper.selectASTNode(CodeSelectHelper.java:111)
	at org.codehaus.groovy.eclipse.search.GroovyOccurrencesFinder.initialize(GroovyOccurrencesFinder.java:221)
	at org.codehaus.groovy.eclipse.editor.GroovyEditor.updateOccurrenceAnnotations(GroovyEditor.java:1243)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor$ActivationListener.windowActivated(JavaEditor.java:1215)
	at org.eclipse.ui.internal.Workbench$11.run(Workbench.java:1084)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.Workbench.fireWindowActivated(Workbench.java:1081)
	at org.eclipse.ui.internal.WorkbenchWindow$15.shellActivated(WorkbenchWindow.java:2304)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4418)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1103)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1088)
	at org.eclipse.swt.widgets.Decorations.WM_ACTIVATE(Decorations.java:1697)
	at org.eclipse.swt.widgets.Shell.WM_ACTIVATE(Shell.java:2277)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4796)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:359)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1656)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2199)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5123)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2547)
	at org.eclipse.swt.widgets.Shell.callWindowProc(Shell.java:506)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4897)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:359)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1656)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2199)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5110)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2552)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3822)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1121)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:693)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:610)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
	at com.kms.katalon.core.application.WorkbenchApplicationStarter.start(WorkbenchApplicationStarter.java:23)
	at com.kms.katalon.application.Application.runGUI(Application.java:191)
	at com.kms.katalon.application.Application.start(Application.java:102)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
	at 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 org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1519)

What am I doing wrong?

Thanks in advance, really appreciate your help!
Bert.

The document of com.azure.core.credential.AzureKeyCredential says

Maven Artifact: com.azure:azure-core:1.11.0

Possibly you need that jar in the Drivers folder.


When I checked the Maven Central repository at
https://mvnrepository.com/artifact/com.microsoft.azure/azure-core

I got confused. There I found the version 0.9.8 is the lastest. But the Microsoft’s document mentions the version 1.11.0. How comes this discrepancy? I have no idea.

@kazurayam in fact latest seems to be 1.12.0, you can grab it here:
https://search.maven.org/artifact/com.azure/azure-core/1.12.0/jar

Microsoft it is known to be not the best at documenting stuff.
digging a bit on github in the readme files here:

will eventually land you here:

https://azure.github.io/azure-sdk/releases/latest/java.html

from where you can go on the sonatype search page for a given library

I guess Microsoft does not respect the Maven Central repository so that they do not push their new developments there.

It’s understandable, as I know in 2018 Microsoft acquired GitHub.

Thank you really much guys!

Adding the Azure Core jar was the solution.

Annoying to see that bad documentation from our MS friends…