You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by shengzhixia <sh...@gmail.com> on 2016/06/06 11:22:46 UTC
Unable to set ContextClassLoader in spark shell
Hello guys!
I am using spark shell which uses TranslatingClassLoader.
scala> Thread.currentThread().getContextClassLoader
res13: ClassLoader =
org.apache.spark.repl.SparkIMain$TranslatingClassLoader@23c767e6
For some reason I want to use another class loader, but when I do
val myclassloader = // create my own classloader
Thread.currentThread.setContextClassLoader(myclassloader)
The setContextClassLoader doesn't seem to work. I still get a
TranslatingClassLoader:
scala> Thread.currentThread().getContextClassLoader
res13: ClassLoader =
org.apache.spark.repl.SparkIMain$TranslatingClassLoader@23c767e6
In my previous Java project I can change class loader without problem. Could
I know why the above method couldn't change class loader in spark shell?
Any way I can achieve it?
Thanks!
--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/Unable-to-set-ContextClassLoader-in-spark-shell-tp27094.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
For additional commands, e-mail: user-help@spark.apache.org
Re: Unable to set ContextClassLoader in spark shell
Posted by Marcelo Vanzin <va...@cloudera.com>.
On Mon, Jun 6, 2016 at 4:22 AM, shengzhixia <sh...@gmail.com> wrote:
> In my previous Java project I can change class loader without problem. Could
> I know why the above method couldn't change class loader in spark shell?
> Any way I can achieve it?
The spark-shell for Scala 2.10 will reset the context class loader
every time you run a statement. Not sure if the 2.11 behavior is the
same (don't see the code in Spark, but it might be in the Scala repl
code).
I'm not sure there is any way to work around it.
--
Marcelo
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
For additional commands, e-mail: user-help@spark.apache.org