Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Dear all, and thank you for your support, in advance.
I have just added some custom jar libraries to my notebook environment but it seems that I cannot import their classes into my Scala notebooks, even if the class loader can see them and I can instanciate them using reflection.
As an example, in Custom Libraries I put "requests_2.12-0.9.0.jar";
now, if in a paragraph I run:
"import request.Requester"
I get
"<console>:26: error: not found: value requests"
but, if in the paragraph I run:
"Class.forName("requests.Requester")"
it works and I can run its methods using reflection.
So: why cannot the notebook import the classes from custom JARS (I tried with several libraries) ?
Thanks. Fabrizio
Solved! Go to Solution.
Hi @Faber1975 ,
Thanks for reaching out to Microsoft Fabric Community.
Thanks for the update and for sharing the details.
It looks like the issue might have been related to the notebook environment not being fully initialized when you first tried to access the custom JAR. Sometimes, classes from a JAR may be available to the classloader but not immediately usable through direct import statements until the session is fully ready. This could explain why it started working correctly later without any changes.
Just as a general note - when working with custom libraries, it's a good idea to make sure any required dependencies are also uploaded, especially if theyโre not already part of the environment. While this may not have been the cause in your case, it can help avoid similar issues in other scenarios.
Glad to hear itโs working now. If the issue happens again, restarting the notebook session usually helps.
Since the issue is resolved, please consider closing this by marking your reply as the accepted solution. This will help others who might face a similar situation.
Thanks again.
Hi @Faber1975
Upload Your JAR to Resources folder
In your nb
%%configure -f
{
"conf": {
"spark.jars": "abfss://<Lakehouse prefix>.dfs.fabric.microsoft.com/<path to JAR>/<JAR file name>.jar"
}
}
import requests.Requester
Thank you @nilendraFabric but unfortunately it does not work. Files uploaded on Resources area are available only as local files (i.e. "file:///synfs/nb_resource/...." not "abfss://.." ) and only after the container has started.
On the other end, if I upload the JAR on the lakehouse and put it into the "Custom Libraries" area of the Environment, its classes are visible to the classloader ("Class.forName.("<my class>").. ") even without the "%%configure" paragraph, but I cannot import them (import <my class>),
For the moment I am working by instancing a Scala REPL at the beginning and using this interpreter to compile code in the paragraphs but it seems crazy to me: kind of a notebook into a notebook ๐
Very strange. This morning, same notebook, it does work!
Hi @Faber1975 ,
Thanks for reaching out to Microsoft Fabric Community.
Thanks for the update and for sharing the details.
It looks like the issue might have been related to the notebook environment not being fully initialized when you first tried to access the custom JAR. Sometimes, classes from a JAR may be available to the classloader but not immediately usable through direct import statements until the session is fully ready. This could explain why it started working correctly later without any changes.
Just as a general note - when working with custom libraries, it's a good idea to make sure any required dependencies are also uploaded, especially if theyโre not already part of the environment. While this may not have been the cause in your case, it can help avoid similar issues in other scenarios.
Glad to hear itโs working now. If the issue happens again, restarting the notebook session usually helps.
Since the issue is resolved, please consider closing this by marking your reply as the accepted solution. This will help others who might face a similar situation.
Thanks again.