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

  • Home
  • SEARCH
  • 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 8543519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:19:17+00:00 2026-06-11T12:19:17+00:00

While running tests with Maven I have encountered a NoClassDefFoundError, caused by ClassNotFoundException. The

  • 0

While running tests with Maven I have encountered a NoClassDefFoundError, caused by ClassNotFoundException. The class which was not found definitely exists in my local repository.

The problematic dependency looks like this: a default scoped dependency depends on a jar which scope is a marked as provided, and the file which was not found by the classloader is located inside that jar. It compiles ok, by the file cannot be found while runnig the app.

I have fixed the error by adding that “provided jar” explicitely to my pom as a runtime-scoped dependency, but I want to understand whats going on.

1) What is the meaning of dependency scope = provided if I am running some tests? I understand that a servlet container can have some provided jars, such as servlet-api.jar, but what about tests? This looks like an error in our pom, isn’t it?
Is there any other case except from servlet-api.jar (and similair web-server jars) when we should use the “provided” scope?

2) I tried to use a maven command-line parameter -U while looking for the solution of this problem. As far as I understand, it forces Maven to check the remote repository and take most fresh the dependencies from there if necessary.
A question is: whats going on if I am not specifying this command? It will always get the outdated dependencies from local repository? If not, then why I need this command?

3) For solving issues like this it is good to know which jars are really on classpath when compiling the code, and which are there when running the code. Is it possible with Maven?

  • 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-11T12:19:18+00:00Added an answer on June 11, 2026 at 12:19 pm

    1) provided always means, that the dependencies shouldn’t be copied to the built artifact. tests with some dependencies declared as provided won’t run as these dependencies are needed at runtime. you can solve this problem by creating an own profile “Test” for example. So in your “Test” profile you declare your dependencies as default scope, this will override the provided scope. After that you can run your tests with following command:

    `mvn <goal> -PTest`
    

    See Introduction on profiles for for information.

    2)as far as i know, the command-line parameter -U will cause to fetch the dependencies freshly, as your repository may be broken (for example, if you changed or deleted files in there).

    3) mvn dependency:tree

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

Sidebar

Related Questions

while running maven from eclipse you have option to execute these launch configurations by
I'm getting this error django.db.utils.IntegrityError: django_content_type.name may not be NULL while running tests via
I´m running UI tests for an RCP application using SWTBot, which works fine while
I am running some profiling tests, and usleep is an useful function. But while
while running: rake snorby:setup getting below error: rake aborted! You have already activated rake
While running my application (which does a good bit of custom drawing) I get
While running my android application in emulator,it shows The application is not installed in
While running code in production, I don't have to interact with the Ember.js runloop
Background While running benchmark tests this morning, my colleagues and I discovered some strange
I am getting the IllegalAccessError while running Android instrumentation tests. This is Logcat output:

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.