Error while reading from neo4j into spark

I follow the steps in (Quickstart - Neo4j Spark Connector) and use the following package:

$SPARK_HOME/bin/spark-shell --packages neo4j-contrib:neo4j-connector-apache-spark_2.12:4.0.1_for_spark_3

Now, in spark shell, when I try to execute this (mentioned in the same site):

 import org.apache.spark.sql.{SaveMode, SparkSession}
 val spark = SparkSession.builder().getOrCreate()
 val df = spark.read.format("org.neo4j.spark.DataSource")
 .option("url", "bolt://localhost:7687")
 .option("authentication.basic.username", "neo4j")
 .option("authentication.basic.password", "neo4j")
 .option("labels", "Person")
 .load()

The following error occur:
java.lang.NoClassDefFoundError: org/apache/spark/sql/sources/v2/ReadSupport

What shall I do to fix the problem?

It may be related to the combination of scala, connector and spark versions you are running - if they dont match exactly you will get an error

neo4j-contrib:neo4j-connector-apache-spark_2.12:4.0.1_for_spark_3

The jars are named like so JARs are named in the form: neo4j-connector-apache-spark_${scala.version}_${connector.version}_for_${spark.version}

From the jar you are using, you would need to have scala 2.12, connector 4.0.1 and spark 3 or above. If you have a different combination of versions then you will get an error. Try using a different jar that supports the combination you have https://neo4j.com/docs/spark/current/overview/