Search code examples
azureamazon-s3migrationazure-cosmosdbaws-glue

Error Migrating from Azure Cosmosdb to AWS S3 - ClassNotFoundException


I'm trying to retrieve data from Azure comsosdb on AWS, I'm using a Glue ETL Job and the source is AWS Glue Studio custom Connector "azure-cosmos-spark_3-3_2-12"

When I run the job I get the error below:

Failed to find data source: com.azure.cosmos.spark. Please find packages at https://spark.apache.org/third-party-projects.html

at org.apache.spark.sql.errors.QueryExecutionErrors$.failedToFindDataSourceError(QueryExecutionErrors.scala:574)
at org.apache.spark.sql.execution.datasources.DataSource$.lookupDataSource(DataSource.scala:675)
at org.apache.spark.sql.execution.datasources.DataSource$.lookupDataSourceV2(DataSource.scala:725)
at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:207)
at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:171)
at com.amazonaws.services.glue.marketplace.connector.CustomDataSourceFactory$.loadSparkDataSource(CustomDataSourceFactory.scala:89)
at com.amazonaws.services.glue.marketplace.connector.CustomDataSourceFactory$.loadDataSource(CustomDataSourceFactory.scala:33)
at com.amazonaws.services.glue.GlueContext.getCustomSource(GlueContext.scala:176)
at com.amazonaws.services.glue.GlueContext.getCustomSourceWithConnection(GlueContext.scala:483)
at com.amazonaws.services.glue.GlueContext.getSourceInternal(GlueContext.scala:975)
at com.amazonaws.services.glue.GlueContext.getSource(GlueContext.scala:783)
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 py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
at py4j.Gateway.invoke(Gateway.java:282)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.ClientServerConnection.waitForCommands(ClientServerConnection.java:182)
at py4j.ClientServerConnection.run(ClientServerConnection.java:106)
at java.lang.Thread.run(Thread.java:750)
Caused by: java.lang.ClassNotFoundException: com.azure.cosmos.spark.DefaultSource
at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at org.apache.spark.sql.execution.datasources.DataSource$.$anonfun$lookupDataSource$5(DataSource.scala:661)
at scala.util.Try$.apply(Try.scala:209)
at org.apache.spark.sql.execution.datasources.DataSource$.$anonfun$lookupDataSource$4(DataSource.scala:661)
at scala.util.Failure.orElse(Try.scala:220)
at org.apache.spark.sql.execution.datasources.DataSource$.lookupDataSource(DataSource.scala:661)

Solution

  • it turned out that the configuration for the custom connector is wrong Class Name should be cosmos.oltp instead of com.azure.cosmos.spark

    I was confused as I got the wrong name from aws docs https://aws.amazon.com/blogs/database/migrate-from-azure-cosmos-db-to-amazon-dynamodb-using-aws-glue/

    enter image description here