LantaoJin commented on a change in pull request #25944: [SPARK-29254][SQL] 
Failed to include jars passed in through --jars when isolatedLoader is enabled
URL: https://github.com/apache/spark/pull/25944#discussion_r329333781
 
 

 ##########
 File path: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/IsolatedClientLoader.scala
 ##########
 @@ -80,10 +80,21 @@ private[hive] object IsolatedClientLoader extends Logging {
       resolvedVersions((resolvedVersion, actualHadoopVersion))
     }
 
+    // HiveMetastoreConnection using maven missed the jars in classpath which 
passed
+    // through --jars. They need to be added back before new 
IsolatedClientLoader()
+    val jarsInClasspath = Utils.getContextOrSparkClassLoader match {
+      case m: MutableURLClassLoader =>
+        val jars = m.getURLs.toSeq
+        logInfo(s"Added jars in classpath to IsolatedClientLoader: $jars")
+        jars
+      case _ =>
+        Seq.empty
+    }
+
     new IsolatedClientLoader(
       hiveVersion(hiveMetastoreVersion),
       sparkConf,
-      execJars = files,
+      execJars = files ++ jarsInClasspath,
 
 Review comment:
   Thank you @AngersZhuuuu 
   1. `SparkContext.getActive.get.jars` will return empty list in the YARN mode.
   2. I think checking JDK is no need since the initialization process of 
MutableURLClassLoader had handled it. BTW I have tested in JDK12.
   ```scala
   case m: MutableURLClassLoader => ...
   case _ => Seq.empty
   ```
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to