Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join 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

Reply
Faber1975
Regular Visitor

Class in Custom JAR library not recognized by the Notebook but available by classloader

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

 

 

 

 

1 ACCEPTED SOLUTION
v-veshwara-msft
Community Support
Community Support

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.

View solution in original post

4 REPLIES 4
v-veshwara-msft
Community Support
Community Support

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.

Faber1975
Regular Visitor

Very strange. This morning, same notebook, it does work!

 

 

 

 

Faber1975
Regular Visitor

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 🙂

 

 

 

 

 

 

nilendraFabric
Community Champion
Community Champion

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

 

 

 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

May FBC25 Carousel

Fabric Monthly Update - May 2025

Check out the May 2025 Fabric update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.