Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredJoin us at FabCon Vienna from September 15-18, 2025, for the ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM. Get registered
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 ,
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.
Very strange. This morning, same notebook, it does work!
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 🙂
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
User | Count |
---|---|
13 | |
4 | |
3 | |
3 | |
3 |
User | Count |
---|---|
8 | |
8 | |
7 | |
6 | |
5 |