Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7862485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:08:43+00:00 2026-06-02T23:08:43+00:00

I have a misunderstanding of how to use maven provided scope and the Java

  • 0

I have a misunderstanding of how to use maven provided scope and the Java classloader.

Say I have a class, MyClass, and this class has a serialize() method that takes an enum that describes what JSON library to use when serializing.

One of these JSON libraries is internal, and included in the JAR that I distribute for MyClass. Simple.

The other JSON library is a 3rd party library that I want to force the user to provide. Thus, I put it under <scope>provided</scope> in my pom.

Everything works for me during tests, but when I try to use my own library from the outside without the 3rd party JSON library in my classpath, I get ClassNotFoundExceptions, even though I’m not making a call to serialize() at all.

I was under the assumption that classes would only be loaded ‘as-needed’, and since I’m not making a call to serialize(), I shouldn’t have any runtime problems. Am I wrong? Is there no way to achieve what I am getting at here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:08:44+00:00Added an answer on June 2, 2026 at 11:08 pm

    Found the issue. I had a static initializer that was making a call to the 3rd party JSON library which was causing the issue.

    I do expect a class not found, if I’m a user of the api and not providing the 3rd party JAR. However, my concern was that I wasn’t making any calls to cause the JAR to be needed. Static initializer threw me off.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class Logger which, among other things has a method Log .
this question can create a misunderstanding: I know I have to use CSS to
I'm having a misunderstanding problem with this use of Linq Query I do have
I have a misunderstanding with the use of flash scope in jsf 2. I
I have an HTML file that has a set of divs with the class
I have an HTML page with a text box. This text box has an
I may have some misunderstanding regarding the use of the UINavigationControllerDelegate protocol. Here is
I have a base class Character which has several classes deriving from it. The
I have a string that looks something like this: Bürstner &nbsp;&nbsp; When I use
This is probably a simple misunderstanding on my part. Have a simple interface: public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.